(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
authorpeter1138
Wed, 26 Apr 2006 20:18:29 +0000
changeset 3667 67cf868114ac
parent 3666 d37f272cc136
child 3668 42325f12e7d8
(svn r4582) - NewGRF: include an additional check to see if a spriteset id is within range.
newgrf.c
--- a/newgrf.c	Wed Apr 26 19:42:05 2006 +0000
+++ b/newgrf.c	Wed Apr 26 20:18:29 2006 +0000
@@ -1319,6 +1319,11 @@
 {
 	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... */