diff --git a/modules/vorbis/resource_importer_ogg_vorbis.cpp b/modules/vorbis/resource_importer_ogg_vorbis.cpp index 83927507984..8a095b0b74f 100644 --- a/modules/vorbis/resource_importer_ogg_vorbis.cpp +++ b/modules/vorbis/resource_importer_ogg_vorbis.cpp @@ -177,13 +177,15 @@ Ref ResourceImporterOggVorbis::import_ogg_vorbis(const Str } granule_pos = packet.granulepos; - PackedByteArray data; - data.resize(packet.bytes); - memcpy(data.ptrw(), packet.packet, packet.bytes); - packet_data.push_back(data); - packet_count++; + if (packet.bytes > 0) { + PackedByteArray data; + data.resize(packet.bytes); + memcpy(data.ptrw(), packet.packet, packet.bytes); + packet_data.push_back(data); + packet_count++; + } } - if (initialized_stream) { + if (initialized_stream && packet_data.size() > 0) { ogg_packet_sequence->push_page(granule_pos, packet_data); } }