[ovs-dev] [PATCH] ovn: Free default db befor exit.

Russell Bryant rbryant at redhat.com
Tue Aug 18 15:24:54 UTC 2015


The static result of default_db() was malloc'd but not freed before
exit.  Make the static result global and free it before exit.

Signed-off-by: Russell Bryant <rbryant at redhat.com>
---
 ovn/northd/ovn-northd.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index 554dba3..9d3d658 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -1016,14 +1016,16 @@ ovnsb_db_changed(struct northd_context *ctx)
     hmap_destroy(&lports_hmap);
 }
 
+
+static char *default_db_;
+
 static const char *
 default_db(void)
 {
-    static char *def;
-    if (!def) {
-        def = xasprintf("unix:%s/db.sock", ovs_rundir());
+    if (!default_db_) {
+        default_db_ = xasprintf("unix:%s/db.sock", ovs_rundir());
     }
-    return def;
+    return default_db_;
 }
 
 static void
@@ -1322,6 +1324,8 @@ main(int argc, char *argv[])
     ovsdb_idl_destroy(ovnnb_idl);
     service_stop();
 
+    free(default_db_);
+
     exit(res);
 }
 
-- 
2.4.3




More information about the dev mailing list