From e80373c823215c8d1ac59a6a1a81dc9233b1eb07 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 13 Mar 2014 00:26:19 -0400 Subject: MADS: Add guard against reading depth value outside bounds of depth surface --- engines/mads/msurface.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp index 2adb3e5b81..e8d391ff89 100644 --- a/engines/mads/msurface.cpp +++ b/engines/mads/msurface.cpp @@ -497,12 +497,14 @@ MSurface *MSurface::flipHorizontal() const { /*------------------------------------------------------------------------*/ int DepthSurface::getDepth(const Common::Point &pt) { - if (_vm->_game->_scene._sceneInfo->_depthStyle == 2) { int bits = (3 - (pt.x % 4)) * 2; byte v = *getBasePtr(pt.x >> 2, pt.y); return v >> bits; } else { + if (pt.x < 0 || pt.y < 0 || pt.x >= this->w || pt.y >= this->h) + return 8; + return *getBasePtr(pt.x, pt.y) & 0xF; } } -- cgit v1.2.3