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:
parent
77598f0708
commit
e1421715e8
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue