(svn r4459) - Newstations: check pointer for NULL before using it.
authorpeter1138
Mon, 17 Apr 2006 18:35:44 +0000
changeset 3573 d120a5847915
parent 3572 dbf23be88773
child 3574 280e134ce515
(svn r4459) - Newstations: check pointer for NULL before using it.
newgrf_station.c
--- a/newgrf_station.c	Mon Apr 17 17:59:42 2006 +0000
+++ b/newgrf_station.c	Mon Apr 17 18:35:44 2006 +0000
@@ -117,6 +117,7 @@
 
 static const RealSpriteGroup *ResolveStationSpriteGroup(const SpriteGroup *spg, const Station *st)
 {
+	if (spg == NULL) return NULL;
 	switch (spg->type) {
 		case SGT_REAL:
 			return &spg->g.real;
@@ -183,6 +184,7 @@
 uint32 GetCustomStationRelocation(const StationSpec *spec, const Station *st, byte ctype)
 {
 	const RealSpriteGroup *rsg = ResolveStationSpriteGroup(spec->spritegroup[ctype], st);
+	if (rsg == NULL) return 0;
 
 	if (rsg->sprites_per_set != 0) {
 		if (rsg->loading_count != 0) return rsg->loading[0]->g.result.result;