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)
This commit is contained in:
Denis Kenzior 2014-07-15 18:44:41 -05:00
parent f2ae753964
commit 5cf28c6dc7
1 changed files with 4 additions and 2 deletions

View File

@ -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++]);