Skip to content

Commit

Permalink
Prevent potential memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
negativeExponent committed Sep 25, 2020
1 parent 6a1bb59 commit 0a9ba07
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions mednafen/FileStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ FileStream::FileStream(const char *path, const int mode)

FileStream::~FileStream()
{
close();
}

uint64 FileStream::read(void *data, uint64 count, bool error_on_eos)
Expand Down
17 changes: 14 additions & 3 deletions mednafen/cdrom/CDAccess_CHD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,21 @@ bool CDAccess_CHD::Load(const std::string &path, bool image_memcache)
return true;
}

CDAccess_CHD::~CDAccess_CHD()
void CDAccess_CHD::Cleanup(void)
{
if (chd != NULL)
chd_close(chd);
if (chd != NULL)
chd_close(chd);

if (hunkmem != NULL)
{
free(hunkmem);
hunkmem = NULL;
}
}

CDAccess_CHD::~CDAccess_CHD()
{
Cleanup();
}

bool CDAccess_CHD::Read_CHD_Hunk_RAW(uint8_t *buf, int32_t lba, CHDFILE_TRACK_INFO* track)
Expand Down

0 comments on commit 0a9ba07

Please sign in to comment.