From db6f272607842a6279fee589fb101f3a1f6148f3 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Mon, 2 Nov 2020 15:55:46 +0100 Subject: [PATCH] genprotimg: fix two memory leaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ==1005844== HEAP SUMMARY: ==1005844== in use at exit: 18,907 bytes in 14 blocks ==1005844== total heap usage: 82 allocs, 68 frees, 32,529 bytes allocated ==1005844== ==1005844== 136 (104 direct, 32 indirect) bytes in 1 blocks are definitely lost in loss record 12 of 14 ==1005844== at 0x483885A: calloc (vg_replace_malloc.c:760) ==1005844== by 0x48C950D: g_malloc0 (gmem.c:132) ==1005844== by 0x100EC41: pv_args_new (pv_args.c:364) ==1005844== by 0x100587F: main (genprotimg.c:122) ==1005844== ==1005844== LEAK SUMMARY: ==1005844== definitely lost: 104 bytes in 1 blocks ==1005844== indirectly lost: 32 bytes in 1 blocks ==1005844== possibly lost: 0 bytes in 0 blocks ==1005844== still reachable: 18,771 bytes in 12 blocks ==1005844== suppressed: 0 bytes in 0 blocks ==1005844== Reachable blocks (those to which a pointer was found) are not shown. ==1005844== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==1005844== ==1005844== For lists of detected and suppressed errors, rerun with: -s ==1005844== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) Signed-off-by: Marc Hartmayer Signed-off-by: Jan Höppner --- genprotimg/src/genprotimg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/genprotimg/src/genprotimg.c b/genprotimg/src/genprotimg.c index 0d825503..c6de381a 100644 --- a/genprotimg/src/genprotimg.c +++ b/genprotimg/src/genprotimg.c @@ -177,5 +177,7 @@ error: rmdir_recursive(tmp_dir, NULL); remove_signal_handler(signals, G_N_ELEMENTS(signals)); g_free(tmp_dir); + g_clear_pointer(&img, pv_img_free); + g_clear_pointer(&args, pv_args_free); exit(ret); }