From: Jon Burgess Date: Sun, 14 Oct 2018 18:10:16 +0000 (+0100) Subject: Fix memory leak in decoder test code X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=9a9f5a7a52d47a6e41048d943a2ab7e54e0948ce;p=libsigrokdecode.git Fix memory leak in decoder test code ==187724== 917 bytes in 1 blocks are definitely lost in loss record 3,046 of 3,207 ==187724== at 0x4C2EBAB: malloc (vg_replace_malloc.c:299) ==187724== by 0x563C435: g_malloc (in /usr/lib64/libglib-2.0.so.0.5600.3) ==187724== by 0x5655D82: g_strdup (in /usr/lib64/libglib-2.0.so.0.5600.3) ==187724== by 0x4E43937: py_str_as_str (util.c:371) ==187724== by 0x4E415E1: srd_decoder_doc_get (decoder.c:892) ==187724== by 0x40281D: test_doc_get (decoder.c:395) ==187724== by 0x53E51D5: srunner_run_tagged (in /usr/lib64/libcheck.so.0.0.0) ==187724== by 0x401237: main (main.c:51) --- diff --git a/tests/decoder.c b/tests/decoder.c index 2298d93..3678410 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -388,11 +388,14 @@ END_TEST START_TEST(test_doc_get) { struct srd_decoder *dec; + char *doc; srd_init(DECODERS_TESTDIR); srd_decoder_load("uart"); dec = srd_decoder_get_by_id("uart"); - fail_unless(srd_decoder_doc_get(dec) != NULL); + doc = srd_decoder_doc_get(dec); + fail_unless(doc != NULL); + g_free(doc); srd_exit(); } END_TEST