[ovs-dev,1/1] ovsdb-client: fix memory leak in is_database_clustered() function.
diff mbox series

Message ID 1569829248-22577-1-git-send-email-damjan.skvarc@gmail.com
State New
Headers show
Series
  • [ovs-dev,1/1] ovsdb-client: fix memory leak in is_database_clustered() function.
Related show

Commit Message

Damijan Skvarc Sept. 30, 2019, 7:40 a.m. UTC
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>
---
 ovsdb/ovsdb-client.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c
index bc12d42..e3ef372 100644
--- a/ovsdb/ovsdb-client.c
+++ b/ovsdb/ovsdb-client.c
@@ -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