]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuxml2argvmock: Don't leak @netdef->ifname
authorMichal Privoznik <mprivozn@redhat.com>
Sat, 9 Jul 2016 06:57:46 +0000 (08:57 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 11 Jul 2016 14:25:08 +0000 (16:25 +0200)
In the mock, we have a stub for virNetDevTapCreate(). However,
the mocked version does not exactly as it's native counterpart.
The function receives a string, which is an interface name that
caller would like to have, but it's not guaranteed that they will
get just that one. If they don't, the function free()-s the one
passed and returns the new one. Just like the mocked version. But
what is the mocked version missing is the free().

==1068== 6 bytes in 1 blocks are definitely lost in loss record 9 of 132
==1068==    at 0x4C29F80: malloc (vg_replace_malloc.c:296)
==1068==    by 0xDE13356: xmlStrndup (in /usr/lib64/libxml2.so.2.9.4)
==1068==    by 0xAE2333E: virXMLPropString (virxml.c:479)
==1068==    by 0xAE45975: virDomainNetDefParseXML (domain_conf.c:9038)
==1068==    by 0xAE5C0BB: virDomainDefParseXML (domain_conf.c:16734)
==1068==    by 0xAE5EB96: virDomainDefParseNode (domain_conf.c:17444)
==1068==    by 0xAE5EA05: virDomainDefParse (domain_conf.c:17391)
==1068==    by 0xAE5EA93: virDomainDefParseFile (domain_conf.c:17415)
==1068==    by 0x433430: testCompareXMLToArgvFiles (qemuxml2argvtest.c:278)
==1068==    by 0x433A18: testCompareXMLToArgvHelper (qemuxml2argvtest.c:414)
==1068==    by 0x446ED4: virTestRun (testutils.c:179)
==1068==    by 0x43A099: mymain (qemuxml2argvtest.c:1016)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
tests/qemuxml2argvmock.c

index e0ec2db4d81a5b7575fc26e0861339601558b235..78a224bd50944141fd5f4eb6f58062b094771e2b 100644 (file)
@@ -118,6 +118,7 @@ virNetDevTapCreate(char **ifname,
     for (i = 0; i < tapfdSize; i++)
         tapfd[i] = STDERR_FILENO + 1 + i;
 
+    VIR_FREE(*ifname);
     return VIR_STRDUP(*ifname, "vnet0");
 }