From: Danny Al-Gaaf Date: Fri, 10 May 2013 13:49:56 +0000 (+0200) Subject: client/SyntheticClient.cc: fix memory leak X-Git-Tag: v0.63~41^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b9fbc8212e685d6db32d81e4f743c5c01eba4b64;p=ceph.git client/SyntheticClient.cc: fix memory leak 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 --- diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index 5e14df2e4456..13337e9d14b5 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -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;