SCI: Truncate channel data in case it goes beyond resource size

Fixes invalid memory access during kq5 floppy ending
This commit is contained in:
Martin Kiewitz 2016-03-08 03:36:02 +01:00
parent 343f1c7f8b
commit 6779340b24

View File

@ -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;