[virt-tools-list] [vhostmd PATCH 10/18] util: Fix potential memory leak
Jim Fehlig
jfehlig at suse.com
Wed Jan 15 22:07:44 UTC 2020
>From coverity scan
vhostmd-1.1/vhostmd/util.c:415:14: warning: Potential leak of memory pointed to by 'cp'
return(NULL);
Signed-off-by: Jim Fehlig <jfehlig at suse.com>
---
vhostmd/util.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/vhostmd/util.c b/vhostmd/util.c
index 1f9545b..599c5c7 100644
--- a/vhostmd/util.c
+++ b/vhostmd/util.c
@@ -415,7 +415,7 @@ char *vu_str_replace(const char *haystack, const char *origstr, const char *news
dest = malloc(strlen(haystack) - (origlen * cnt) + (newlen * cnt) + 1);
if (dest == NULL) {
- return(NULL);
+ goto out;
}
*dest = '\0';
@@ -428,6 +428,8 @@ char *vu_str_replace(const char *haystack, const char *origstr, const char *news
cp = p + origlen;
}
strcat(dest, cp);
+
+out:
free(tempstr);
return dest;
--
2.16.4
More information about the virt-tools-list
mailing list