From 9f4c39f3099f7ecbccbc0be521d25ec6185cf2e3 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Thu, 25 May 2017 22:12:45 -0400 Subject: [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 Signed-off-by: Erik Skultety --- 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 9dffbc7360..95b5274368 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 {