From 5d359832980043c645be7327ed699dd821a005e1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 6 Oct 2021 20:13:03 +0200 Subject: [PATCH] decoder/openmpt: catch libopenmpt exceptions in scan_stream() Fixes crash bug. --- src/decoder/plugins/OpenmptDecoderPlugin.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/decoder/plugins/OpenmptDecoderPlugin.cxx b/src/decoder/plugins/OpenmptDecoderPlugin.cxx index bedb8341d..1e8547d1f 100644 --- a/src/decoder/plugins/OpenmptDecoderPlugin.cxx +++ b/src/decoder/plugins/OpenmptDecoderPlugin.cxx @@ -126,7 +126,7 @@ mod_decode(DecoderClient &client, InputStream &is) static bool openmpt_scan_stream(InputStream &is, TagHandler &handler) noexcept -{ +try { const auto buffer = mod_loadfile(&openmpt_domain, nullptr, is); if (buffer.IsNull()) { LogWarning(openmpt_domain, "could not load stream"); @@ -145,6 +145,13 @@ openmpt_scan_stream(InputStream &is, TagHandler &handler) noexcept handler.OnTag(TAG_PERFORMER, mod.get_metadata("tracker").c_str()); return true; +} catch (...) { + /* libopenmpt usually throws openmpt::exception, but "may + additionally throw any exception thrown by the standard + library which are all derived from std::exception", we + let's just catch all here */ + LogError(std::current_exception(), "libopenmpt failed"); + return false; } static const char *const mod_suffixes[] = {