]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Ceph: Fix memory leak in chain_flistxattr()
authorLi Wang <liwang@ubuntukylin.com>
Thu, 7 Nov 2013 02:44:30 +0000 (10:44 +0800)
committerSage Weil <sage@inktank.com>
Thu, 7 Nov 2013 03:00:52 +0000 (19:00 -0800)
Free allocated memory before return.

Signed-off-by: Li Wang <liwang@ubuntukylin.com>
Reviewed-by: Sage Weil <sage@inktank.com>
src/os/chain_xattr.cc

index 8ca815689ed36c169719092fd6360799ed267982..c020c9db843987b02ea5c31b8957869a0cfd0441 100644 (file)
@@ -388,6 +388,10 @@ done:
 
 int chain_flistxattr(int fd, char *names, size_t len) {
   int r;
+  char *p;
+  const char * end;
+  char *dest;
+  char *dest_end;
 
   if (!len)
     return sys_flistxattr(fd, names, len) * 2;
@@ -403,12 +407,12 @@ int chain_flistxattr(int fd, char *names, size_t len) {
 
   r = sys_flistxattr(fd, full_buf, total_len);
   if (r < 0)
-    return r;
+    goto done;
 
-  char *p = full_buf;
-  const char *end = full_buf + r;
-  char *dest = names;
-  char *dest_end = names + len;
+  p = full_buf;
+  end = full_buf + r;
+  dest = names;
+  dest_end = names + len;
 
   while (p < end) {
     char name[CHAIN_XATTR_MAX_NAME_LEN * 2 + 16];