Fix minor memory leaks found by valgrind.
authorBen Pfaff <blp@nicira.com>
Tue, 27 Mar 2012 21:09:14 +0000 (14:09 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 28 Mar 2012 21:54:48 +0000 (14:54 -0700)
All of these leaks are in normally short-lived programs, so none of them
is very important.

Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/ovsdb-data.c
ovsdb/ovsdb-client.c
ovsdb/ovsdb-tool.c
utilities/ovs-ofctl.c
utilities/ovs-vsctl.c

index bb8781c25d5c87dd4ef062af349fb88bf3f475a9..d9787185fb917c1df2cdf5d9d99127bccb4db15c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009, 2010, 2011 Nicira Networks
+/* Copyright (c) 2009, 2010, 2011, 2012 Nicira Networks
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -590,6 +590,7 @@ ovsdb_atom_from_string(union ovsdb_atom *atom,
 
     error = ovsdb_atom_check_constraints(atom, base);
     if (error) {
+        ovsdb_atom_destroy(atom, base->type);
         msg = ovsdb_error_to_string(error);
         ovsdb_error_destroy(error);
     }
index 53da6ae27fe75d72aecfce2fabef8b3480867333..077e3a8cc31536ddc19a2bcc46613a2d7a6228f0 100644 (file)
@@ -885,10 +885,15 @@ dump_table(const struct ovsdb_table_schema *ts, struct json_array *rows)
             struct cell *cell = table_add_cell(&t);
             cell->json = ovsdb_datum_to_json(&data[y][x], &columns[x]->type);
             cell->type = &columns[x]->type;
+            ovsdb_datum_destroy(&data[y][x], &columns[x]->type);
         }
+        free(data[y]);
     }
     table_print(&t, &table_style);
     table_destroy(&t);
+
+    free(data);
+    free(columns);
 }
 
 static void
@@ -957,6 +962,10 @@ do_dump(struct jsonrpc *rpc, const char *database,
 
         dump_table(ts, &rows->u.array);
     }
+
+    jsonrpc_msg_destroy(reply);
+    free(tables);
+    ovsdb_schema_destroy(schema);
 }
 
 static void
index ecf998b38ff392a15e46ca9020247b24a62c5c42..e83b49a129f24f7c41c61e4fd21ff31c6b155654 100644 (file)
@@ -252,6 +252,10 @@ compact_or_convert(const char *src_name, const char *dst_name,
     }
 
     lockfile_unlock(dst_lock);
+
+    if (in_place) {
+        free((char *) dst_name);
+    }
 }
 
 static void
index 3e9f4628e7140dd6200e0f53ef15077453ebe3b6..2b91a2894ffd66609855d89dd11e46f2aaa95012 100644 (file)
@@ -363,6 +363,7 @@ dump_transaction(const char *vconn_name, struct ofpbuf *request)
     open_vconn(vconn_name, &vconn);
     run(vconn_transact(vconn, request, &reply), "talking to %s", vconn_name);
     ofp_print(stdout, reply->data, reply->size, verbosity + 1);
+    ofpbuf_delete(reply);
     vconn_close(vconn);
 }
 
@@ -1135,6 +1136,7 @@ do_packet_out(int argc, char *argv[])
         ofpbuf_delete(packet);
     }
     vconn_close(vconn);
+    ofpbuf_uninit(&actions);
 }
 
 static void
@@ -1413,6 +1415,7 @@ fte_free_all(struct classifier *cls)
         classifier_remove(cls, &fte->rule);
         fte_free(fte);
     }
+    classifier_destroy(cls);
 }
 
 /* Searches 'cls' for an FTE matching 'rule', inserting a new one if
index 0caf57e8e7419355dcd42de4cba3f6874780a7a9..d752a547d1bb9d11956e1ef63caa61fd22fd9df0 100644 (file)
@@ -1370,6 +1370,7 @@ cmd_add_br(struct vsctl_context *ctx)
                                 br_name, parent_name, vlan, br_name, br->vlan);
                 }
             }
+            free_info(&info);
             return;
         }
     }
@@ -1730,6 +1731,7 @@ add_port(struct vsctl_context *ctx,
 
             svec_destroy(&want_names);
             svec_destroy(&have_names);
+            free_info(&info);
 
             return;
         }
@@ -3540,6 +3542,7 @@ is_condition_satisfied(const struct vsctl_table_class *table,
         }
 
         ovsdb_atom_destroy(&want_key, column->type.key.type);
+        ovsdb_datum_destroy(&b, &type);
     } else {
         struct ovsdb_datum want_datum;