From: Ján Tomko Date: Tue, 27 Aug 2013 11:47:57 +0000 (+0200) Subject: virsh: free the caps list properly if one of them is invalid X-Git-Tag: v1.1.2-rc1~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14d5328681448267dfc0812948fa2c6ec4dfa7d4;p=thirdparty%2Flibvirt.git virsh: free the caps list properly if one of them is invalid VIR_FREE(caps) is not enough to free an array allocated by vshStringToArray. ==17== 4 bytes in 1 blocks are definitely lost in loss record 4 of 728 ==17== by 0x4EFFC44: virStrdup (virstring.c:554) ==17== by 0x128B10: _vshStrdup (virsh.c:125) ==17== by 0x129164: vshStringToArray (virsh.c:218) ==17== by 0x157BB3: cmdNodeListDevices (virsh-nodedev.c:409) https://bugzilla.redhat.com/show_bug.cgi?id=1001536 --- diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index b34a3b1752..3a2d12b9d1 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -413,8 +413,8 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) for (i = 0; i < ncaps; i++) { if ((cap_type = virNodeDevCapTypeFromString(caps[i])) < 0) { vshError(ctl, "%s", _("Invalid capability type")); - VIR_FREE(caps); - return false; + ret = false; + goto cleanup; } switch (cap_type) {