diff mbox series

[ovs-dev,1/1] ovsdb-client: fix memory leak while executing database backup

Message ID 1570602864-7007-1-git-send-email-damjan.skvarc@gmail.com
State Accepted
Commit 76c67e9ac3ad1e95249403777c5cd2b528633142
Headers show
Series [ovs-dev,1/1] ovsdb-client: fix memory leak while executing database backup | expand

Commit Message

Damijan Skvarc Oct. 9, 2019, 6:34 a.m. UTC
valgrind detects this leak while running functional test "ovsdb-client backup and restore"

==25401== 1,068 (240 direct, 828 indirect) bytes in 6 blocks are definitely lost in loss record 22 of 22
==25401==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==25401==    by 0x449DA4: xmalloc (util.c:138)
==25401==    by 0x43012D: json_create (json.c:1451)
==25401==    by 0x43012D: json_array_create_empty (json.c:186)
==25401==    by 0x43012D: json_parser_push_array (json.c:1279)
==25401==    by 0x4303CF: json_parser_input (json.c:1407)
==25401==    by 0x4312F1: json_lex_input (json.c:991)
==25401==    by 0x43193B: json_parser_feed (json.c:1149)
==25401==    by 0x4329FA: jsonrpc_recv.part.7 (jsonrpc.c:332)
==25401==    by 0x432D3B: jsonrpc_recv (jsonrpc.c:297)
==25401==    by 0x432D3B: jsonrpc_recv_block (jsonrpc.c:402)
==25401==    by 0x4330EB: jsonrpc_transact_block (jsonrpc.c:436)
==25401==    by 0x409246: do_backup (ovsdb-client.c:2008)
==25401==    by 0x405F76: main (ovsdb-client.c:282)

the problem was in db_backup() function, where _uuid json node was detached from
its parent "row" json node, but never destroyed afterwards.

Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
---
 ovsdb/ovsdb-client.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Ben Pfaff Oct. 9, 2019, 6:04 p.m. UTC | #1
On Wed, Oct 09, 2019 at 08:34:24AM +0200, Damijan Skvarc wrote:
> valgrind detects this leak while running functional test "ovsdb-client backup and restore"

Thanks, applied to master.
diff mbox series

Patch

diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c
index 8878462..72756eb 100644
--- a/ovsdb/ovsdb-client.c
+++ b/ovsdb/ovsdb-client.c
@@ -2061,6 +2061,7 @@  do_backup(struct jsonrpc *rpc, const char *database,
             char uuid_s[UUID_LEN + 1];
             snprintf(uuid_s, sizeof uuid_s, UUID_FMT, UUID_ARGS(&atom.uuid));
             json_object_put(output_rows, uuid_s, json_clone(row));
+            json_destroy(uuid_json);
         }
         json_object_put(output_txn, table_name, output_rows);
     }