aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2016-05-25 07:17:20 +0200
committerStrangerke2016-05-25 07:17:20 +0200
commit454bcdc51ce9cf39aaa162140862cfb4e01a2d57 (patch)
treea75311cb20a7b41c65f7d33c3339f4b64dc9a7d9 /engines
parent03f7ab132e04772412f87d1854a344f1287330c1 (diff)
downloadscummvm-rg350-454bcdc51ce9cf39aaa162140862cfb4e01a2d57.tar.gz
scummvm-rg350-454bcdc51ce9cf39aaa162140862cfb4e01a2d57.tar.bz2
scummvm-rg350-454bcdc51ce9cf39aaa162140862cfb4e01a2d57.zip
GNAP: Strengthen sanity checks in drawBitmap
Diffstat (limited to 'engines')
-rw-r--r--engines/gnap/gamesys.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/engines/gnap/gamesys.cpp b/engines/gnap/gamesys.cpp
index bd94558d1a..f4b6c1c2c1 100644
--- a/engines/gnap/gamesys.cpp
+++ b/engines/gnap/gamesys.cpp
@@ -388,25 +388,26 @@ Graphics::Surface *GameSys::loadBitmap(int resourceId) {
}
void GameSys::drawBitmap(int resourceId) {
+ assert(_backgroundSurface);
+
Graphics::Surface *bmpSurface = loadBitmap(resourceId);
- if (!bmpSurface || !_backgroundSurface) {
- debugC(kDebugBasic, "GameSys::drawBitmap() Error loading the bitmap");
- return;
- }
- if (bmpSurface->format != _backgroundSurface->format ||
- bmpSurface->w != _backgroundSurface->w || bmpSurface->h != _backgroundSurface->h) {
- debugC(kDebugBasic, "GameSys::drawBitmap() Different bitmap properties than current background");
- } else {
- byte *src = (byte *)bmpSurface->getPixels();
- byte *dst = (byte *)_backgroundSurface->getPixels();
- const int pitch = bmpSurface->pitch;
- int height = bmpSurface->h;
- while (height--) {
- memcpy(dst, src, pitch);
- src += pitch;
- dst += pitch;
- }
+ if (!bmpSurface)
+ error("GameSys::drawBitmap() Error loading the bitmap");
+
+ if (bmpSurface->format != _backgroundSurface->format
+ || bmpSurface->w != _backgroundSurface->w || bmpSurface->h != _backgroundSurface->h)
+ error("GameSys::drawBitmap() Different bitmap properties than current background");
+
+ byte *src = (byte *)bmpSurface->getPixels();
+ byte *dst = (byte *)_backgroundSurface->getPixels();
+ const int pitch = bmpSurface->pitch;
+ int height = bmpSurface->h;
+ while (height--) {
+ memcpy(dst, src, pitch);
+ src += pitch;
+ dst += pitch;
}
+
bmpSurface->free();
delete bmpSurface;