]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Plug memory on virDomainDiskDefParseXML
authorAlex Jia <ajia@redhat.com>
Fri, 3 Feb 2012 08:42:22 +0000 (16:42 +0800)
committerOsier Yang <jyang@redhat.com>
Fri, 3 Feb 2012 08:57:15 +0000 (16:57 +0800)
Detected by valgrind. Leak is introduced in commit 397e6a7.

* src/conf/domain_conf.c(virDomainDiskDefParseXML): fix memory leak.

How to reproduce?
% make -C tests check TESTS=qemuxml2argvtest
% cd tests && valgrind -v --leak-check=full ./qemuxml2argvtest

* Actual result:

==16352== 4 bytes in 1 blocks are definitely lost in loss record 12 of 147
==16352==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==16352==    by 0x39D90A67DD: xmlStrndup (xmlstring.c:45)
==16352==    by 0x4E83D5: virDomainDiskDefParseXML (domain_conf.c:2894)
==16352==    by 0x4F542D: virDomainDefParseXML (domain_conf.c:7626)
==16352==    by 0x4F8683: virDomainDefParseNode (domain_conf.c:8390)
==16352==    by 0x4F904E: virDomainDefParse (domain_conf.c:8340)
==16352==    by 0x41C626: testCompareXMLToArgvHelper (qemuxml2argvtest.c:105)
==16352==    by 0x41DED1: virtTestRun (testutils.c:142)
==16352==    by 0x418172: mymain (qemuxml2argvtest.c:486)
==16352==    by 0x41D5C7: virtTestMain (testutils.c:697)
==16352==    by 0x39CF01ECDC: (below main) (in /lib64/libc-2.12.so)

Signed-off-by: Alex Jia <ajia@redhat.com>
src/conf/domain_conf.c

index aeef9db46c887dc54849a8ebea4b41605a407090..26e24f04589615cdd2dfc0c8be049b6c467cab50 100644 (file)
@@ -3413,6 +3413,7 @@ cleanup:
     VIR_FREE(bus);
     VIR_FREE(type);
     VIR_FREE(snapshot);
+    VIR_FREE(rawio);
     VIR_FREE(target);
     VIR_FREE(source);
     while (nhosts > 0) {