From e6bb622032e8e98b85609f9a237aef5e56cb925f Mon Sep 17 00:00:00 2001 From: Zhang Bo Date: Tue, 28 Apr 2015 09:16:13 +0800 Subject: [PATCH] tests: free ChardevInfo correctly in qemumonitorjsontest The free callback should be qemuMonitorChardevInfoFree rather than just 'free' when virHashCreate'ing the chardevInfo hash. ==29959== 24 bytes in 2 blocks are definitely lost in loss record 19 of 53 ==29959== at 0x4C29F80: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==29959== by 0xB95C679: strdup (in /lib64/libc-2.20.so) ==29959== by 0x63C6546: virStrdup (virstring.c:709) ==29959== by 0x4805ED: qemuMonitorJSONExtractChardevInfo (qemu_monitor_json.c:3429) ==29959== by 0x4807A5: qemuMonitorJSONGetChardevInfo (qemu_monitor_json.c:3479) ==29959== by 0x434AEC: testQemuMonitorJSONqemuMonitorJSONGetChardevInfo (qemumonitorjsontest.c:1824) ==29959== by 0x436F2F: virtTestRun (testutils.c:211) ==29959== by 0x436932: mymain (qemumonitorjsontest.c:2404) ==29959== by 0x4382EA: virtTestMain (testutils.c:863) ==29959== by 0x436B27: main (qemumonitorjsontest.c:2423) Signed-off-by: Zhang Bo Signed-off-by: Zhou Yimin --- tests/qemumonitorjsontest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index c6379b643a..0f82fd821e 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -28,7 +28,7 @@ #include "virerror.h" #include "virstring.h" #include "cpu/cpu.h" - +#include "qemu/qemu_monitor.h" #define VIR_FROM_THIS VIR_FROM_NONE @@ -1782,7 +1782,7 @@ testQemuMonitorJSONqemuMonitorJSONGetChardevInfo(const void *data) if (!test) return -1; - if (!(info = virHashCreate(32, (virHashDataFree) free)) || + if (!(info = virHashCreate(32, qemuMonitorChardevInfoFree)) || !(expectedInfo = virHashCreate(32, NULL))) goto cleanup; -- GitLab