From 37bee2fde3242e75b494e455c6d08a31880df05f Mon Sep 17 00:00:00 2001 From: DeeJayLSP Date: Tue, 17 Jun 2025 00:53:49 -0300 Subject: [PATCH] Fix broken WAV info list tag parsing --- scene/resources/audio_stream_wav.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scene/resources/audio_stream_wav.cpp b/scene/resources/audio_stream_wav.cpp index a3602cd73a..889b31e084 100644 --- a/scene/resources/audio_stream_wav.cpp +++ b/scene/resources/audio_stream_wav.cpp @@ -875,21 +875,29 @@ Ref AudioStreamWAV::load_from_buffer(const Vector &p_st char list_id[4]; file->get_buffer((uint8_t *)&list_id, 4); + uint32_t end_of_chunk = file_pos + chunksize - 8; if (list_id[0] == 'I' && list_id[1] == 'N' && list_id[2] == 'F' && list_id[3] == 'O') { // 'INFO' list type. // The size of an entry can be arbitrary. - uint32_t end_of_chunk = file_pos + chunksize - 4; while (file->get_position() < end_of_chunk) { char info_id[4]; file->get_buffer((uint8_t *)&info_id, 4); uint32_t text_size = file->get_32(); + if (text_size == 0) { + continue; + } Vector text; text.resize(text_size); file->get_buffer((uint8_t *)&text[0], text_size); + // Skip padding byte if text_size is odd + if (text_size & 1) { + file->get_8(); + } + // The data is always an ASCII string. ASCII is a subset of UTF-8. String tag; tag.append_utf8(&info_id[0], 4);