]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
addr_parsing: fix memory leak
authorSage Weil <sage@inktank.com>
Fri, 28 Sep 2012 14:05:27 +0000 (07:05 -0700)
committerSage Weil <sage@inktank.com>
Fri, 28 Sep 2012 20:18:05 +0000 (13:18 -0700)
CID 717082: Resource leak (RESOURCE_LEAK)
At (4): Variable "buf" going out of scope leaks the storage it points to.

Signed-off-by: Sage Weil <sage@inktank.com>
src/include/addr_parsing.c

index bc7dcf3bd86a89ec85b907ec3a5932d8b0f86aa1..2a469f9a9b7bfba9917340024dc8dd2d1da6ccda 100644 (file)
@@ -55,8 +55,10 @@ char *resolve_addrs(const char *orig_str)
 
   len = BUF_SIZE;
   new_str = (char *)malloc(len);
-  if (!new_str)
+  if (!new_str) {
+    free(buf);
     return NULL;
+  }
 
   pos = 0;