mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-10 03:40:25 +00:00
SAGA2: Added safeguards to sprite unpacking
This commit is contained in:
parent
36e9a264c8
commit
9565ea67a3
@ -110,6 +110,11 @@ void unpackSprite(gPixelMap *map, uint8 *sprData) {
|
||||
|
||||
while (true) {
|
||||
byte trans = *sprData++;
|
||||
if (bytes < trans) {
|
||||
warning("unpackSprite: too many trans %d < %d", bytes, trans);
|
||||
trans = bytes;
|
||||
break;
|
||||
}
|
||||
memset(dst, 0, trans);
|
||||
dst += trans;
|
||||
bytes -= trans;
|
||||
@ -118,6 +123,10 @@ void unpackSprite(gPixelMap *map, uint8 *sprData) {
|
||||
break;
|
||||
|
||||
byte fill = *sprData++;
|
||||
if (bytes < fill) {
|
||||
warning("unpackSprite: too many bytes %d < %d", bytes, fill);
|
||||
fill = bytes;
|
||||
}
|
||||
memcpy(dst, sprData, fill);
|
||||
dst += fill;
|
||||
bytes -= fill;
|
||||
|
@ -530,11 +530,11 @@ void *LoadResource(hResContext *con, uint32 id, const char desc[]) {
|
||||
|
||||
idString[0] = id;
|
||||
idString[1] = 0;
|
||||
debugC(3, kDebugResources, "Loading resource %d (%s, %s)", id, tag2str(id), desc);
|
||||
debugC(3, kDebugResources, "LoadResource(): Loading resource %d (%s, %s)", id, tag2str(id), desc);
|
||||
|
||||
size = con->size(id);
|
||||
if (size <= 0 || !con->seek(id)) {
|
||||
error("Error reading resource ID '%s'.", &idString);
|
||||
error("LoadResource(): Error reading resource ID '%s'.", &idString);
|
||||
}
|
||||
|
||||
// Allocate the buffer
|
||||
@ -552,11 +552,11 @@ Common::SeekableReadStream *loadResourceToStream(hResContext *con, uint32 id, co
|
||||
|
||||
idString[0] = id;
|
||||
idString[1] = 0;
|
||||
debugC(3, kDebugResources, "Loading resource %d (%s, %s)", id, tag2str(id), desc);
|
||||
debugC(3, kDebugResources, "loadResourceToStream(): Loading resource %d (%s, %s)", id, tag2str(id), desc);
|
||||
|
||||
size = con->size(id);
|
||||
if (size <= 0 || !con->seek(id)) {
|
||||
error("Error reading resource ID '%s'.", &idString);
|
||||
error("loadResourceToStream(): Error reading resource ID '%s'.", &idString);
|
||||
}
|
||||
|
||||
// Allocate the buffer
|
||||
@ -577,10 +577,11 @@ RHANDLE LoadResourceToHandle(hResContext *con, uint32 id, const char desc[]) {
|
||||
|
||||
idString[0] = id;
|
||||
idString[1] = 0;
|
||||
debugC(3, kDebugResources, "LoadResourceToHandle(): Loading resource %d (%s, %s)", id, tag2str(id), desc);
|
||||
|
||||
size = con->size(id);
|
||||
if (size <= 0 || !con->seek(id)) {
|
||||
error("Error reading resource ID '%s'.", &idString);
|
||||
error("LoadResourceToHandle(): Error reading resource ID '%s'.", &idString);
|
||||
}
|
||||
|
||||
// Allocate the buffer
|
||||
@ -978,6 +979,9 @@ APPFUNC(cmdWindowFunc) {
|
||||
|
||||
GameMode::modeStackPtr[GameMode::modeStackCtr - 1]->handleKey(key, qual);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user