Skip to content

Commit

Permalink
MidiSource: Close source SDL_RWops before throwing error
Browse files Browse the repository at this point in the history
  • Loading branch information
Ancurio committed Jul 9, 2015
1 parent 1e9e24e commit 5382cc1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/midisource.cpp
Expand Up @@ -626,9 +626,20 @@ struct MidiSource : ALDataSource, MidiReadHandler
std::vector<uint8_t> data(dataLen);

if (SDL_RWread(&ops, &data[0], 1, dataLen) < dataLen)
{
SDL_RWclose(&ops);
throw Exception(Exception::MKXPError, "Reading midi data failed");
}

readMidi(this, data);
try
{
readMidi(this, data);
}
catch (const Exception &)
{
SDL_RWclose(&ops);
throw;
}

synth = shState->midiState().allocateSynth();

Expand Down

0 comments on commit 5382cc1

Please sign in to comment.