aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/gnap/gamesys.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/engines/gnap/gamesys.cpp b/engines/gnap/gamesys.cpp
index d31854d06e..11ef6fd3d7 100644
--- a/engines/gnap/gamesys.cpp
+++ b/engines/gnap/gamesys.cpp
@@ -1116,7 +1116,10 @@ void GameSys::fatUpdateFrame() {
if (_newSpriteDrawItemsCount > 0) {
debugC(kDebugBasic, "_newSpriteDrawItemsCount: %d", _newSpriteDrawItemsCount);
for (int k = 0; k < _newSpriteDrawItemsCount; ++k) {
- if (_gfxItemsCount < 50) {
+ // The original was allowing a buffer overflow.
+ // In order to fit in memory, insertIndex + 1 + (_gfxItemsCount - InsertIndex) must be
+ // smaller than the size _gfxItems array (50).
+ if (_gfxItemsCount + 1 < 50) {
int insertIndex;
seqLocateGfx(-1, _newSpriteDrawItems[k]._id, &insertIndex);
if (_gfxItemsCount != insertIndex)