From 810990249211bceced672bc1e864b0b6bfe5a15e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 18 Jan 2022 14:50:58 +0100 Subject: [PATCH] stb_vorbis: Add clearer error messages when failing to import OGG file Fixes #56895. --- modules/stb_vorbis/audio_stream_ogg_vorbis.cpp | 4 ++-- modules/stb_vorbis/resource_importer_ogg_vorbis.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp index 1dcfd25b04b..2c0bf5743dd 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp @@ -185,8 +185,8 @@ void AudioStreamOGGVorbis::set_data(const PoolVector &p_data) { w.release(); alloc_try *= 2; } else { - ERR_FAIL_COND(alloc_try == MAX_TEST_MEM); - ERR_FAIL_COND(ogg_stream == nullptr); + ERR_FAIL_COND_MSG(alloc_try == MAX_TEST_MEM, "Failed allocating memory for OGG Vorbis stream."); + ERR_FAIL_COND_MSG(!ogg_stream, "OGG Vorbis decoding failed. Check that your data is a valid OGG Vorbis audio stream."); stb_vorbis_info info = stb_vorbis_get_info(ogg_stream); diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp index 2dfba67d910..de5bebd7859 100644 --- a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp +++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp @@ -91,7 +91,7 @@ Error ResourceImporterOGGVorbis::import(const String &p_source_file, const Strin ogg_stream.instance(); ogg_stream->set_data(data); - ERR_FAIL_COND_V(!ogg_stream->get_data().size(), ERR_FILE_CORRUPT); + ERR_FAIL_COND_V_MSG(!ogg_stream->get_data().size(), ERR_FILE_CORRUPT, "Couldn't import file as AudioStreamOGGVorbis: " + p_source_file); ogg_stream->set_loop(loop); ogg_stream->set_loop_offset(loop_offset);