diff --git a/modules/vorbis/resource_importer_ogg_vorbis.cpp b/modules/vorbis/resource_importer_ogg_vorbis.cpp index bf5d964d39f..7b8d14741b0 100644 --- a/modules/vorbis/resource_importer_ogg_vorbis.cpp +++ b/modules/vorbis/resource_importer_ogg_vorbis.cpp @@ -212,11 +212,13 @@ Ref ResourceImporterOggVorbis::load_from_buffer(const Vect granule_pos = packet.granulepos; } - PackedByteArray data; - data.resize(packet.bytes); - memcpy(data.ptrw(), packet.packet, packet.bytes); - sorted_packets[granule_pos].push_back(data); - packet_count++; + if (packet.bytes > 0) { + PackedByteArray data; + data.resize(packet.bytes); + memcpy(data.ptrw(), packet.packet, packet.bytes); + sorted_packets[granule_pos].push_back(data); + packet_count++; + } } Vector> packet_data; for (const KeyValue>> &pair : sorted_packets) { @@ -224,7 +226,7 @@ Ref ResourceImporterOggVorbis::load_from_buffer(const Vect packet_data.push_back(packets); } } - if (initialized_stream) { + if (initialized_stream && packet_data.size() > 0) { ogg_packet_sequence->push_page(ogg_page_granulepos(&page), packet_data); } }