summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2007-01-16 22:10:35 +0000
committerpeter1138 <peter1138@openttd.org>2007-01-16 22:10:35 +0000
commitf19b87df08347bd1f6e0c6f778a0f7fc053516e1 (patch)
treec190e64324ec0e0cd9bf069812a4c8a2b7f8e8fa
parent0c9e65d8cc0651a4e2f3bffb2c0864549f78bb5b (diff)
downloadopenttd-f19b87df08347bd1f6e0c6f778a0f7fc053516e1.tar.xz
(svn r8166) -Fix (r7797): Protect against out of bounds access to the sprite ptr
list.
-rw-r--r--src/spritecache.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/spritecache.cpp b/src/spritecache.cpp
index 1f9d838ed..3c6aef018 100644
--- a/src/spritecache.cpp
+++ b/src/spritecache.cpp
@@ -107,7 +107,7 @@ bool SpriteExists(SpriteID id)
{
/* Special case for Sprite ID zero -- its position is also 0... */
if (id == 0) return true;
-
+ if (id >= _spritecache_items) return false;
return GetSpriteCache(id)->file_pos != 0;
}
@@ -386,7 +386,7 @@ const void *GetRawSprite(SpriteID sprite)
SpriteCache *sc;
void* p;
- assert(sprite < MAX_SPRITES);
+ assert(sprite < _spritecache_items);
sc = GetSpriteCache(sprite);