MidiSource: Close source SDL_RWops before throwing error

This commit is contained in:
Jonas Kulla 2015-07-09 12:38:04 +02:00
parent 1e9e24e45c
commit 5382cc11a3
1 changed files with 12 additions and 1 deletions

View File

@ -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");
}
try
{
readMidi(this, data);
}
catch (const Exception &)
{
SDL_RWclose(&ops);
throw;
}
synth = shState->midiState().allocateSynth();