]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Fix Memory Leak in virStorageFileGetMetadataRecurse()
authorNehal J Wani <nehaljw.kkd1@gmail.com>
Thu, 17 Apr 2014 23:15:21 +0000 (04:45 +0530)
committerJán Tomko <jtomko@redhat.com>
Fri, 18 Apr 2014 07:17:07 +0000 (09:17 +0200)
While running virstoragetest, valgrind pointed out the following
memory leak:

==8142== 2 bytes in 1 blocks are definitely lost in loss record 1 of 92
==8142==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==8142==    by 0x4E7B53E: mdir_name (dirname-lgpl.c:78)
==8142==    by 0x4CBE2B0: virStorageFileGetMetadataInternal (virstoragefile.c:595)
==8142==    by 0x4CBE651: virStorageFileGetMetadataFromFDInternal (virstoragefile.c:1086)
==8142==    by 0x4CBEEB4: virStorageFileGetMetadataRecurse (virstoragefile.c:1175)
==8142==    by 0x4CBF1DE: virStorageFileGetMetadata (virstoragefile.c:1270)
==8142==    by 0x4028AD: testStorageChain (virstoragetest.c:275)
==8142==    by 0x407B91: virtTestRun (testutils.c:201)
==8142==    by 0x4039D7: mymain (virstoragetest.c:534)
==8142==    by 0x40830D: virtTestMain (testutils.c:789)
==8142==    by 0x3E6CE1ED1C: (below main) (libc-start.c:226)

...62 times

src/util/virstoragefile.c

index ea80c1d88bdd517a2a22e9a885c2cef59e80f97b..73cfef02bed657569b05aff3418b8cd25baf94a0 100644 (file)
@@ -1213,6 +1213,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
             meta->backingMeta = backing;
         }
     }
+    VIR_FREE(backingDirectory);
     return ret;
 }