[libvirt] [PATCH] util: fix memory leak in virSocketAddrFormatFull

The @ipv6_host allocated in virAsprintf may be lost when virAsprintf addrstr failed. Signed-off-by: Yi Wang <wang.yi59@zte.com.cn> --- src/util/virsocketaddr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c index 9dffbc7..95b5274 100644 --- a/src/util/virsocketaddr.c +++ b/src/util/virsocketaddr.c @@ -417,8 +417,10 @@ virSocketAddrFormatFull(const virSocketAddr *addr, if (virAsprintf(&addrstr, "%s%s%s", ipv6_host ? ipv6_host : host, - separator ? separator : ":", port) == -1) + separator ? separator : ":", port) == -1) { + VIR_FREE(ipv6_host); goto error; + } VIR_FREE(ipv6_host); } else { -- 1.8.3.1

On Thu, May 25, 2017 at 10:12:45PM -0400, Yi Wang wrote:
The @ipv6_host allocated in virAsprintf may be lost when virAsprintf addrstr failed.
Signed-off-by: Yi Wang <wang.yi59@zte.com.cn> --- src/util/virsocketaddr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c index 9dffbc7..95b5274 100644 --- a/src/util/virsocketaddr.c +++ b/src/util/virsocketaddr.c @@ -417,8 +417,10 @@ virSocketAddrFormatFull(const virSocketAddr *addr,
if (virAsprintf(&addrstr, "%s%s%s", ipv6_host ? ipv6_host : host, - separator ? separator : ":", port) == -1) + separator ? separator : ":", port) == -1) { + VIR_FREE(ipv6_host); goto error; + }
VIR_FREE(ipv6_host); } else { -- 1.8.3.1
ACK and pushed. Thanks, Erik
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (2)
-
Erik Skultety
-
Yi Wang