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

CID 717070 Resource leak (CWE-404)

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

index 5e14df2e445639cea6330aa623f879bd3a105851..13337e9d14b540c3124afc58203a212b2017a544 100644 (file)
@@ -2413,6 +2413,11 @@ int SyntheticClient::read_random(string& fn, int size, int rdsize)   // size is
 
     //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;