Skip to content

Commit

Permalink
Fix possible mem leak
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram committed Mar 30, 2018
1 parent c7eafec commit 5821a3a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/RageSoundReader_FileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,19 @@ RageSoundReader_FileReader *RageSoundReader_FileReader::TryOpenFile( RageFileBas
#endif

#if defined(HAS_MP3)
if( !format.CompareNoCase("mp3") )
if (!format.CompareNoCase("mp3")) {
if (Sample != nullptr)
delete Sample;
Sample = new RageSoundReader_MP3;
}
#endif

#if defined(HAS_OGG)
if( !format.CompareNoCase("oga") || !format.CompareNoCase("ogg") )
if (!format.CompareNoCase("oga") || !format.CompareNoCase("ogg")) {
if (Sample != nullptr)
delete Sample;
Sample = new RageSoundReader_Vorbisfile;
}
#endif

if( !Sample )
Expand Down

0 comments on commit 5821a3a

Please sign in to comment.