]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/rgw_rest.cc: fix 4K memory leak 42/head
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Fri, 8 Feb 2013 16:17:59 +0000 (17:17 +0100)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Sun, 10 Feb 2013 09:05:06 +0000 (10:05 +0100)
Fix 4K memory leak in case RGWClientIO::read() fails in
read_all_chunked_input().

Error from cppcheck was:
Checking src/rgw/rgw_rest.cc...
[src/rgw/rgw_rest.cc:688]: (error) Memory leak: data

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/rgw/rgw_rest.cc

index 72aab14c522b9ff900e16881f17c0912d9ed1680..ab3927e7a627b0e94ada2d3dfdfda5e57a6f111e 100644 (file)
@@ -684,8 +684,10 @@ static int read_all_chunked_input(req_state *s, char **pdata, int *plen)
   int read_len = 0, len = 0;
   do {
     int r = s->cio->read(data + len, need_to_read, &read_len);
-    if (r < 0)
+    if (r < 0) {
+      free(data);
       return r;
+    }
 
     len += read_len;