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