diff --git a/src/decoder/plugins/GmeDecoderPlugin.cxx b/src/decoder/plugins/GmeDecoderPlugin.cxx index e853450e6..422e843be 100644 --- a/src/decoder/plugins/GmeDecoderPlugin.cxx +++ b/src/decoder/plugins/GmeDecoderPlugin.cxx @@ -25,6 +25,7 @@ #include "tag/TagHandler.hxx" #include "fs/Path.hxx" #include "fs/AllocatedPath.hxx" +#include "util/ScopeExit.hxx" #include "util/FormatString.hxx" #include "util/AllocatedString.hxx" #include "util/UriUtil.hxx" @@ -141,6 +142,8 @@ gme_file_decode(Decoder &decoder, Path path_fs) return; } + AtScopeExit(emu) { gme_delete(emu); }; + FormatDebug(gme_domain, "emulator type '%s'\n", gme_type_system(gme_type(emu))); @@ -153,7 +156,6 @@ gme_file_decode(Decoder &decoder, Path path_fs) gme_err = gme_track_info(emu, &ti, container.track); if (gme_err != nullptr) { LogWarning(gme_domain, gme_err); - gme_delete(emu); return; } @@ -172,7 +174,6 @@ gme_file_decode(Decoder &decoder, Path path_fs) SampleFormat::S16, GME_CHANNELS, error)) { LogError(error); - gme_delete(emu); return; } @@ -209,8 +210,6 @@ gme_file_decode(Decoder &decoder, Path path_fs) if (gme_track_ended(emu)) break; } while (cmd != DecoderCommand::STOP); - - gme_delete(emu); } static void