From: Roopa Prabhu Date: Fri, 14 Oct 2011 20:41:46 +0000 (-0700) Subject: macvtap: avoid invalid free X-Git-Tag: v0.9.7-rc1~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80b077ee5ea0dd899b87d370f9fa892e727832f5;p=thirdparty%2Flibvirt.git macvtap: avoid invalid free Commit 0472f39 plugged a leak, but introduced another bug: Actually looks like physfndev is conditionally allocated in getPhysfnDev Its better to modify getPhysfnDev to allocate physfndev every time. --- diff --git a/src/util/macvtap.c b/src/util/macvtap.c index a020c9058b..7fd6eb54b9 100644 --- a/src/util/macvtap.c +++ b/src/util/macvtap.c @@ -964,7 +964,11 @@ getPhysfnDev(const char *linkdev, */ *vf = PORT_SELF_VF; - *physfndev = (char *)linkdev; + *physfndev = strdup(linkdev); + if (!*physfndev) { + virReportOOMError(); + rc = -1; + } } return rc;