Fixed an issue that could cause a crash when encountering a zero-length packet in an OGG stream.

A zero-length memcpy into a null pointer itself does not fail, but for gcc with optimizations, this can cause incorrect code to be generated further down the line since the pointer is then assumed to be non-null.
Now stripping zero-length packets and pages without packets from the OggPacketSequence during import. This prevents various warning and error messages for files that end on a zero-length packet.

(cherry picked from commit a4db4ae658)
This commit is contained in:
Michael Wörner 2024-01-16 11:31:51 +01:00 committed by Rémi Verschelde
parent 77598f0708
commit e1421715e8
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 8 additions and 6 deletions

View File

@ -177,13 +177,15 @@ Ref<AudioStreamOggVorbis> ResourceImporterOggVorbis::import_ogg_vorbis(const Str
}
granule_pos = packet.granulepos;
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);
}
}