From 5cf28c6dc72c94ccc509a3f9a1b8a58acdba73bf Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 15 Jul 2014 18:44:41 -0500 Subject: [PATCH] unit: Fix memory leak ==7978== 29 bytes in 3 blocks are definitely lost in loss record 2 of 2 ==7978== at 0x4C2C66D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==7978== by 0x4012FD: l_malloc (util.c:62) ==7978== by 0x4018EF: l_util_hexstring (util.c:372) ==7978== by 0x40118E: ie_test (in /home/denkenz/iwd-master/unit/test-ie) ==7978== by 0x401BE7: l_test_run (test.c:83) ==7978== by 0x401016: main (in /home/denkenz/iwd-master/unit/test-ie) --- unit/test-ie.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/unit/test-ie.c b/unit/test-ie.c index 7c7ad449..aca96725 100644 --- a/unit/test-ie.c +++ b/unit/test-ie.c @@ -50,13 +50,15 @@ static void ie_test(const void *data) struct ie_tlv_iter iter; struct ie *ie; unsigned int count = 0, pos = 0; + char *str; ie_tlv_iter_init(&iter, test->buf, test->len); while (ie_tlv_iter_next(&iter)) { ie = (struct ie *)&test->buf[pos]; - printf("IE %d [%d/%d/%s]\n", count, ie->type, ie->len, - l_util_hexstring(&test->buf[pos + 2], ie->len)); + str = l_util_hexstring(&test->buf[pos + 2], ie->len); + printf("IE %d [%d/%d/%s]\n", count, ie->type, ie->len, str); + l_free(str); assert(iter.tag == test->buf[pos++]); assert(iter.len == test->buf[pos++]);