From a34eba019c4a247e96b3aaed24ce6d11fa5ec372 Mon Sep 17 00:00:00 2001 From: Yifeng Sun Date: Fri, 12 Jan 2018 09:45:31 -0800 Subject: [PATCH] ovsdb-client: Fix memory leaks This two leaks are reported by valgrind (testing ovsdb-client backup and restore): 890 (56 direct, 834 indirect) bytes in 1 blocks are definitely lost in loss record 71 of 73 by 0x42DE22: xcalloc (util.c:103) by 0x40DD8C: ovsdb_schema_create (ovsdb.c:34) by 0x40E0B5: ovsdb_schema_from_json (ovsdb.c:196) by 0x406DA5: fetch_schema (ovsdb-client.c:415) by 0x408478: do_restore (ovsdb-client.c:1595) by 0x405BCD: main (ovsdb-client.c:170) 2,688 (88 direct, 2,600 indirect) bytes in 1 blocks are definitely lost in loss record 73 of 73 by 0x42DE84: xmalloc (util.c:120) by 0x40E61F: ovsdb_create (ovsdb.c:329) by 0x40BA22: ovsdb_file_open__ (file.c:201) by 0x40845A: do_restore (ovsdb-client.c:1592) by 0x405BCD: main (ovsdb-client.c:170) Signed-off-by: Yifeng Sun Signed-off-by: Ben Pfaff --- ovsdb/ovsdb-client.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c index 0ab4d66f1b2..faa6bdb4da0 100644 --- a/ovsdb/ovsdb-client.c +++ b/ovsdb/ovsdb-client.c @@ -1612,6 +1612,7 @@ do_restore(struct jsonrpc *rpc, const char *database, VLOG_INFO("%s", ds_cstr(&s)); ds_destroy(&s); } + ovsdb_schema_destroy(schema2); struct json *txn = json_array_create_empty(); json_array_add(txn, json_string_create(schema->name)); @@ -1653,6 +1654,7 @@ do_restore(struct jsonrpc *rpc, const char *database, json_array_add(txn, ins_op); } } + ovsdb_destroy(backup); struct jsonrpc_msg *rq = jsonrpc_create_request("transact", txn, NULL); struct jsonrpc_msg *reply; check_txn(jsonrpc_transact_block(rpc, rq, &reply), &reply);