]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client/SyntheticClient.cc: fix another memory leak
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Fri, 10 May 2013 13:54:46 +0000 (15:54 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Fri, 10 May 2013 22:02:56 +0000 (00:02 +0200)
Fix memory leak in read_random: call delete[] on buf before
call new[] again in the for-loop.

CID 717071 Resource leak (CWE-404)

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

index 13337e9d14b540c3124afc58203a212b2017a544..7a2ab63a199831372c213ec4a5c3ead2d8591a27 100644 (file)
@@ -2415,7 +2415,7 @@ int SyntheticClient::read_random(string& fn, int size, int rdsize)   // size is
 
     // cleanup before call 'new'
     if (buf != NULL) {
-       delete [] buf;
+       delete[] buf;
        buf = NULL;
     }
     if ( x < 0.5) 
@@ -2586,6 +2586,11 @@ int SyntheticClient::read_random_ex(string& fn, int size, int rdsize)   // size
     
     //dout(0) << "RANDOM NUMBER RETURN |" << x << "|" << dendl;
     
+    // cleanup before call 'new'
+    if (buf != NULL) {
+       delete[] buf;
+       buf = NULL;
+    }
     if ( x < 0.5) 
       {
         //dout(0) << "DECIDED TO READ " << x << dendl;