mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 23:31:53 -05:00
Merge pull request #87246 from bs-mwoerner/ogg_crash
Fix a possible crash when importing an OGG file with zero-length packets
This commit is contained in:
@@ -212,11 +212,13 @@ Ref<AudioStreamOggVorbis> ResourceImporterOggVorbis::load_from_buffer(const Vect
|
|||||||
granule_pos = packet.granulepos;
|
granule_pos = packet.granulepos;
|
||||||
}
|
}
|
||||||
|
|
||||||
PackedByteArray data;
|
if (packet.bytes > 0) {
|
||||||
data.resize(packet.bytes);
|
PackedByteArray data;
|
||||||
memcpy(data.ptrw(), packet.packet, packet.bytes);
|
data.resize(packet.bytes);
|
||||||
sorted_packets[granule_pos].push_back(data);
|
memcpy(data.ptrw(), packet.packet, packet.bytes);
|
||||||
packet_count++;
|
sorted_packets[granule_pos].push_back(data);
|
||||||
|
packet_count++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Vector<Vector<uint8_t>> packet_data;
|
Vector<Vector<uint8_t>> packet_data;
|
||||||
for (const KeyValue<uint64_t, Vector<Vector<uint8_t>>> &pair : sorted_packets) {
|
for (const KeyValue<uint64_t, Vector<Vector<uint8_t>>> &pair : sorted_packets) {
|
||||||
@@ -224,7 +226,7 @@ Ref<AudioStreamOggVorbis> ResourceImporterOggVorbis::load_from_buffer(const Vect
|
|||||||
packet_data.push_back(packets);
|
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);
|
ogg_packet_sequence->push_page(ogg_page_granulepos(&page), packet_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user