aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorSven Hesse2007-02-05 19:48:12 +0000
committerSven Hesse2007-02-05 19:48:12 +0000
commit7082e5828931cc1f86d4a733ae46d492337ab6ae (patch)
tree9819ec61564f769187d58303f471d18b36f6452e /engines
parent193349fd606129d23361b274038385c40a3eb95e (diff)
downloadscummvm-rg350-7082e5828931cc1f86d4a733ae46d492337ab6ae.tar.gz
scummvm-rg350-7082e5828931cc1f86d4a733ae46d492337ab6ae.tar.bz2
scummvm-rg350-7082e5828931cc1f86d4a733ae46d492337ab6ae.zip
Corrected the clipping of _pressedMapX/_pressedMapY, to avoid accessing invalid memory (also possible fix for bug #1652551)
svn-id: r25395
Diffstat (limited to 'engines')
-rw-r--r--engines/gob/goblin.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/engines/gob/goblin.cpp b/engines/gob/goblin.cpp
index 223835049d..46d49b46a1 100644
--- a/engines/gob/goblin.cpp
+++ b/engines/gob/goblin.cpp
@@ -798,6 +798,8 @@ void Goblin::adjustDest(int16 posX, int16 posY) {
}
}
+ _pressedMapX = CLIP((int) _pressedMapX, 0, _vm->_map->_mapWidth - 1);
+ _pressedMapY = CLIP((int) _pressedMapY, 0, _vm->_map->_mapHeight - 1);
}
void Goblin::adjustTarget(void) {
@@ -819,6 +821,8 @@ void Goblin::adjustTarget(void) {
_pressedMapX++;
}
}
+ _pressedMapX = CLIP((int) _pressedMapX, 0, _vm->_map->_mapWidth - 1);
+ _pressedMapY = CLIP((int) _pressedMapY, 0, _vm->_map->_mapHeight - 1);
}
void Goblin::targetDummyItem(Gob_Object *gobDesc) {
@@ -984,6 +988,8 @@ void Goblin::targetItem(void) {
}
}
}
+ _pressedMapX = CLIP((int) _pressedMapX, 0, _vm->_map->_mapWidth - 1);
+ _pressedMapY = CLIP((int) _pressedMapY, 0, _vm->_map->_mapHeight - 1);
}
void Goblin::moveFindItem(int16 posX, int16 posY) {
@@ -1021,8 +1027,8 @@ void Goblin::moveFindItem(int16 posX, int16 posY) {
break;
}
- _pressedMapX = MIN(posX / 12, _vm->_map->_mapWidth - 1);
- _pressedMapY = MIN(posY / 6, _vm->_map->_mapHeight - 1);
+ _pressedMapX = posX / 12;
+ _pressedMapY = posY / 6;
if (_vm->_map->_itemsMap[_pressedMapY][_pressedMapX] == 0
&& i < 20) {
@@ -1063,6 +1069,8 @@ void Goblin::moveFindItem(int16 posX, int16 posY) {
_pressedMapX = posX / 12;
_pressedMapY = posY / 6;
}
+ _pressedMapX = CLIP((int) _pressedMapX, 0, _vm->_map->_mapWidth - 1);
+ _pressedMapY = CLIP((int) _pressedMapY, 0, _vm->_map->_mapHeight - 1);
}
void Goblin::moveCheckSelect(int16 framesCount, Gob_Object * gobDesc, int16 *pGobIndex,