mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 15:21:56 -05:00
Fix broken WAV info list tag parsing
This commit is contained in:
@@ -875,21 +875,29 @@ Ref<AudioStreamWAV> AudioStreamWAV::load_from_buffer(const Vector<uint8_t> &p_st
|
|||||||
|
|
||||||
char list_id[4];
|
char list_id[4];
|
||||||
file->get_buffer((uint8_t *)&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') {
|
if (list_id[0] == 'I' && list_id[1] == 'N' && list_id[2] == 'F' && list_id[3] == 'O') {
|
||||||
// 'INFO' list type.
|
// 'INFO' list type.
|
||||||
// The size of an entry can be arbitrary.
|
// The size of an entry can be arbitrary.
|
||||||
uint32_t end_of_chunk = file_pos + chunksize - 4;
|
|
||||||
while (file->get_position() < end_of_chunk) {
|
while (file->get_position() < end_of_chunk) {
|
||||||
char info_id[4];
|
char info_id[4];
|
||||||
file->get_buffer((uint8_t *)&info_id, 4);
|
file->get_buffer((uint8_t *)&info_id, 4);
|
||||||
|
|
||||||
uint32_t text_size = file->get_32();
|
uint32_t text_size = file->get_32();
|
||||||
|
if (text_size == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Vector<char> text;
|
Vector<char> text;
|
||||||
text.resize(text_size);
|
text.resize(text_size);
|
||||||
file->get_buffer((uint8_t *)&text[0], 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.
|
// The data is always an ASCII string. ASCII is a subset of UTF-8.
|
||||||
String tag;
|
String tag;
|
||||||
tag.append_utf8(&info_id[0], 4);
|
tag.append_utf8(&info_id[0], 4);
|
||||||
|
|||||||
Reference in New Issue
Block a user