From ef7eaa925748c17765079b837eae5d42e6dd948e Mon Sep 17 00:00:00 2001 From: Nipun Garg Date: Sat, 22 Jun 2019 22:22:28 +0530 Subject: HDB: Add NULL checking to getMapBG/FGTileFlags() --- engines/hdb/map-loader.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'engines/hdb') diff --git a/engines/hdb/map-loader.cpp b/engines/hdb/map-loader.cpp index 0e18a71ed9..0cf84e4f69 100644 --- a/engines/hdb/map-loader.cpp +++ b/engines/hdb/map-loader.cpp @@ -691,14 +691,20 @@ uint32 Map::getMapBGTileFlags(int x, int y) { if (x < 0 || x >= _width || y < 0 || y >= _height) { return 0; } - return g_hdb->_drawMan->getTile(_background[y * _width + x])->_flags; + Tile* tile = g_hdb->_drawMan->getTile(_foreground[y * _width + x]); + if (tile) + return tile->_flags; + return 0; } uint32 Map::getMapFGTileFlags(int x, int y) { if (x < 0 || x >= _width || y < 0 || y >= _height) { return 0; } - return g_hdb->_drawMan->getTile(_foreground[y * _width + x])->_flags; + Tile* tile = g_hdb->_drawMan->getTile(_foreground[y * _width + x]); + if (tile) + return tile->_flags; + return 0; } uint16 Map::getMapBGTileIndex(int x, int y) { -- cgit v1.2.3