[vhostmd PATCH 10/18] util: Fix potential memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>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@xxxxxxxx>
---
 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


_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list




[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux