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>
// cleanup before call 'new'
if (buf != NULL) {
- delete [] buf;
+ delete[] buf;
buf = NULL;
}
if ( x < 0.5)
//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;