]> git.proxmox.com Git - ovs.git/commitdiff
ovsdb-client: fix memory leak in is_database_clustered() function.
authorDamijan Skvarc <damjan.skvarc@gmail.com>
Mon, 30 Sep 2019 07:40:48 +0000 (09:40 +0200)
committerBen Pfaff <blp@ovn.org>
Mon, 30 Sep 2019 20:37:36 +0000 (13:37 -0700)
Memory leak is reported while running test suite. It is evidenced with the
following report:

==18447== 1,868 (48 direct, 1,820 indirect) bytes in 1 blocks are definitely lost in loss record 45 of 45
==18447==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==18447==    by 0x449C02: xcalloc (util.c:121)
==18447==    by 0x432949: jsonrpc_msg_from_json (jsonrpc.c:697)
==18447==    by 0x432A8F: jsonrpc_parse_received_message (jsonrpc.c:472)
==18447==    by 0x432A8F: jsonrpc_recv.part.7 (jsonrpc.c:338)
==18447==    by 0x432D0B: jsonrpc_recv (jsonrpc.c:297)
==18447==    by 0x432D0B: jsonrpc_recv_block (jsonrpc.c:402)
==18447==    by 0x4330BB: jsonrpc_transact_block (jsonrpc.c:436)
==18447==    by 0x40A7C1: is_database_clustered (ovsdb-client.c:1624)
==18447==    by 0x40AE3F: do_needs_conversion (ovsdb-client.c:1670)
==18447==    by 0x405F76: main (ovsdb-client.c:282)

Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
ovsdb/ovsdb-client.c

index bfc90e6f7f85a4ef98d94683c021dfa881bf45de..784e2da68aa6e86e69dbdafd4819275d8026964f 100644 (file)
@@ -1627,7 +1627,9 @@ is_database_clustered(struct jsonrpc *rpc, const char *database)
 
     const struct json *row = parse_database_info_reply(
         reply, jsonrpc_get_name(rpc), database, NULL);
-    return !strcmp(parse_string_column(row, "model"), "clustered");
+    bool clustered = !strcmp(parse_string_column(row, "model"), "clustered");
+    jsonrpc_msg_destroy(reply);
+    return clustered;
 }
 
 static void