From bc77a4f2b8229f13557316122f4fd07d41c1f471 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Mon, 18 Dec 2006 10:46:06 +0000 Subject: (svn r7503) -Codechange: [NewGRF] Add bounds checking for spriteset cargo types. (NewCargo support will change this rule a bit...) --- newgrf.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'newgrf.c') diff --git a/newgrf.c b/newgrf.c index 7a294c655..440cfbf31 100644 --- a/newgrf.c +++ b/newgrf.c @@ -1843,6 +1843,11 @@ static void FeatureMapSpriteGroup(byte *buf, int len) if (ctype == 0xFE) ctype = GC_DEFAULT_NA; if (ctype == 0xFF) ctype = GC_PURCHASE; + if (ctype >= NUM_GLOBAL_CID) { + grfmsg(GMS_WARN, "FeatureMapSpriteGroup: Cargo type %d out of range, skipping.", ctype); + continue; + } + statspec->spritegroup[ctype] = _cur_grffile->spritegroups[groupid]; } } @@ -1919,6 +1924,11 @@ static void FeatureMapSpriteGroup(byte *buf, int len) if (ctype == GC_INVALID) ctype = GC_PURCHASE; + if (ctype >= NUM_GLOBAL_CID) { + grfmsg(GMS_WARN, "FeatureMapSpriteGroup: Cargo type %d out of range, skipping.", ctype); + continue; + } + if (wagover) { SetWagonOverrideSprites(engine, ctype, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); } else { -- cgit v1.2.3-54-g00ecf