Skip to content

Commit

Permalink
Merge pull request #87246 from bs-mwoerner/ogg_crash
Browse files Browse the repository at this point in the history
Fix a possible crash when importing an OGG file with zero-length packets
  • Loading branch information
akien-mga committed Feb 14, 2024
2 parents a1cc379 + a4db4ae commit 9705ac4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions modules/vorbis/resource_importer_ogg_vorbis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,21 @@ Ref<AudioStreamOggVorbis> 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<Vector<uint8_t>> packet_data;
for (const KeyValue<uint64_t, Vector<Vector<uint8_t>>> &pair : sorted_packets) {
for (const Vector<uint8_t> &packets : pair.value) {
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);
}
}
Expand Down

0 comments on commit 9705ac4

Please sign in to comment.