From 2c93d4719954a617b1ca15aa5a417c5481a68ff6 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Wed, 26 Apr 2006 20:18:29 +0000 Subject: [PATCH] (svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range. --- newgrf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/newgrf.c b/newgrf.c index 88e7f08752..f7c4d52b63 100644 --- a/newgrf.c +++ b/newgrf.c @@ -1319,6 +1319,11 @@ static SpriteGroup* CreateGroupFromGroupID(byte setid, byte type, uint16 spritei { if (HASBIT(spriteid, 15)) return NewCallBackResultSpriteGroup(spriteid); + if (spriteid >= _cur_grffile->spriteset_numsets) { + grfmsg(GMS_WARN, "NewSpriteGroup(0x%02X:0x%02X): Sprite set %u invalid, max %u", setid, type, spriteid, _cur_grffile->spriteset_numsets); + return NULL; + } + /* Check if the sprite is within range. This can fail if the Action 0x01 * is skipped, as TTDPatch mandates that Action 0x02s must be processed. * We don't have that rule, but must live by the Patch... */