[netcf-devel] [PATCH] debian: avoid a memory leak when listing interfaces
Eric Blake
eblake at redhat.com
Tue Aug 13 13:02:10 UTC 2013
Leak reported via Natanael Copa on IRC when used by libvirt:
==623== 5,677,056 bytes in 693 blocks are definitely lost in loss record 3,354 of 3,358
==623== at 0x4C1138C: malloc (vg_replace_malloc.c:270)
==623== by 0x5B4A9F3: open_memstream (in /lib/libuClibc-0.9.33.2.so)
==623== by 0x5B485AF: vasprintf (in /lib/libuClibc-0.9.33.2.so)
==623== by 0x10BE7C8B: ???
==623== by 0x10BE7EE2: ???
==623== by 0x10BE8473: ???
==623== by 0x10BE8A53: ???
==623== by 0x109BD755: ???
==623== by 0x109BE47D: ???
==623== by 0x53450EF: virConnectListDefinedInterfaces (in /home/ncopa/aports/main/libvirt/src/libvirt-1.1.1/src/.libs/libvirt.so.0.1001.1)
Even without symbols, the lone call to vasprintf in drv_debian was
a pretty blatant leak.
* src/drv_debian.c (interface_deps): Free path when done with it.
Signed-off-by: Eric Blake <eblake at redhat.com>
---
src/drv_debian.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/drv_debian.c b/src/drv_debian.c
index d762a5d..370eccd 100644
--- a/src/drv_debian.c
+++ b/src/drv_debian.c
@@ -140,16 +140,17 @@ static int interface_deps(struct netcf *ncf, char ***slaves, const char *fmt, ..
r = vasprintf(&path, fmt, args);
va_end(args);
if (r < 0) {
path = NULL;
ERR_NOMEM(1, ncf);
}
nmatches = aug_match(aug, path, &matches);
+ FREE(path);
ERR_COND_BAIL(nmatches < 0, ncf, EOTHER);
if (!nmatches)
return 0;
for (int i = 0 ; i < nmatches ; i++) {
r = aug_get(aug, matches[i], &devs);
ERR_COND_BAIL(r < 0, ncf, EOTHER);
--
1.8.3.1
More information about the netcf-devel
mailing list