MidiSource: Close source SDL_RWops before throwing error
This commit is contained in:
parent
1e9e24e45c
commit
5382cc11a3
|
@ -626,9 +626,20 @@ struct MidiSource : ALDataSource, MidiReadHandler
|
||||||
std::vector<uint8_t> data(dataLen);
|
std::vector<uint8_t> data(dataLen);
|
||||||
|
|
||||||
if (SDL_RWread(&ops, &data[0], 1, dataLen) < dataLen)
|
if (SDL_RWread(&ops, &data[0], 1, dataLen) < dataLen)
|
||||||
|
{
|
||||||
|
SDL_RWclose(&ops);
|
||||||
throw Exception(Exception::MKXPError, "Reading midi data failed");
|
throw Exception(Exception::MKXPError, "Reading midi data failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
readMidi(this, data);
|
readMidi(this, data);
|
||||||
|
}
|
||||||
|
catch (const Exception &)
|
||||||
|
{
|
||||||
|
SDL_RWclose(&ops);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
synth = shState->midiState().allocateSynth();
|
synth = shState->midiState().allocateSynth();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue