Skip to content

Commit

Permalink
ovsdb-tool: Fix json leak while showing clustered log.
Browse files Browse the repository at this point in the history
The json read from file is never freed in ovsdb-tool show-log
for a clustered database:

 ERROR: LeakSanitizer: detected memory leaks

 Direct leak of 10774760 byte(s) in 269369 object(s) allocated from:
    0 0x50cc32 in malloc (ovsdb/ovsdb-tool+0x50cc32)
    1 0x6e7b6b in xmalloc__ lib/util.c:140:15
    2 0x6e7b6b in xmalloc lib/util.c:175:12
    3 0x6494f6 in json_create lib/json.c:1489:25
    4 0x64a8a7 in json_object_create lib/json.c:263:25
    5 0x6525f3 in json_parser_push_object lib/json.c:1311:25
    6 0x6525f3 in json_parser_input lib/json.c:1409:13
    7 0x64f6c4 in json_parser_feed lib/json.c:1126:17
    8 0x5694b5 in parse_body ovsdb/log.c:412:9
    9 0x5694b5 in ovsdb_log_read ovsdb/log.c:477:13
   10 0x54d294 in do_show_log_cluster ovsdb/ovsdb-tool.c:1069:27
   11 0x54d294 in do_show_log ovsdb/ovsdb-tool.c:1115:9
   12 0x63b7b1 in ovs_cmdl_run_command__ lib/command-line.c:247:17
   13 0x5488a5 in main ovsdb/ovsdb-tool.c:82:5
   14 0xe0eb49 in __libc_start_call_main (/lib64/libc.so.6+0x27b49)
   15 0xe0ec0a in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x27c0a)
   16 0x471fe4 in _start (ovsdb/ovsdb-tool+0x471fe4)

Fixes: 1b1d2e6 ("ovsdb: Introduce experimental support for clustered databases.")
Reported-by: Dumitru Ceara <[email protected]>
Acked-by: Dumitru Ceara <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
igsilya committed Aug 3, 2023
1 parent d4d068f commit 8b1795c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions ovsdb/ovsdb-tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,7 @@ do_show_log_cluster(struct ovsdb_log *log)
free(s);
}

json_destroy(json);
putchar('\n');
}

Expand Down

0 comments on commit 8b1795c

Please sign in to comment.