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 <oscar.zhangbo@huawei.com>
Signed-off-by: Zhou Yimin <zhouyimin@huawei.com>
This commit is contained in:
Zhang Bo 2015-04-28 09:16:13 +08:00 committed by Michal Privoznik
parent 6f5d29f40d
commit e6bb622032

View File

@ -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;