Skip to content

Commit

Permalink
Fixed|FileHandle: Fixed memory leak in FileHandle
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Dec 6, 2012
1 parent b7e2e57 commit b745171
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions doomsday/engine/src/filesys/filehandle.cpp
Expand Up @@ -200,6 +200,12 @@ FileHandle::~FileHandle()
{
close();

// Free any cached data.
if(d->data)
{
M_Free(d->data); d->data = 0;
}

#if 0
// Copy this file to the used object pool for recycling.
Sys_Lock(mutex);
Expand All @@ -217,17 +223,14 @@ FileHandle& FileHandle::close()
if(!d->flags.open) return *this;
if(d->hndl)
{
fclose(d->hndl); d->hndl = NULL;
fclose(d->hndl); d->hndl = 0;
}
else
// Free any cached data.
if(d->data)
{
// Free the stored data.
if(d->data)
{
M_Free(d->data); d->data = NULL;
}
M_Free(d->data); d->data = 0;
}
d->pos = NULL;
d->pos = 0;
d->flags.open = false;
return *this;
}
Expand Down

0 comments on commit b745171

Please sign in to comment.