diff --git a/engines/saga2/blitters.cpp b/engines/saga2/blitters.cpp index 3ceb6cb4a5f..53ee29b37c6 100644 --- a/engines/saga2/blitters.cpp +++ b/engines/saga2/blitters.cpp @@ -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; diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp index 712d8a621f4..be10ebfe441 100644 --- a/engines/saga2/main.cpp +++ b/engines/saga2/main.cpp @@ -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; } }