mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-01 15:09:47 +00:00
SCI: Truncate channel data in case it goes beyond resource size
Fixes invalid memory access during kq5 floppy ending
This commit is contained in:
parent
343f1c7f8b
commit
6779340b24
@ -688,6 +688,12 @@ SoundResource::SoundResource(uint32 resourceNr, ResourceManager *resMan, SciVers
|
||||
|
||||
channel->data = resource->data + dataOffset;
|
||||
channel->size = READ_LE_UINT16(data + 4);
|
||||
|
||||
if (dataOffset + channel->size > resource->size) {
|
||||
warning("Invalid size inside sound resource %d: track %d, channel %d", resourceNr, trackNr, channelNr);
|
||||
channel->size = resource->size - dataOffset;
|
||||
}
|
||||
|
||||
channel->curPos = 0;
|
||||
channel->number = *channel->data;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user