From 80b077ee5ea0dd899b87d370f9fa892e727832f5 Mon Sep 17 00:00:00 2001 From: Roopa Prabhu Date: Fri, 14 Oct 2011 13:41:46 -0700 Subject: [PATCH] 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. --- src/util/macvtap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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;