From 5f83b41456b051892a404f7c053860bc1876f990 Mon Sep 17 00:00:00 2001 From: buginator Date: Mon, 18 Oct 2010 22:11:16 -0400 Subject: [PATCH] Make sure pointer is valid before using it. refs ticket:2171 git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/branches/2.3@11698 4a71c877-e1ca-e34f-864e-861f7616d084 (cherry picked from commit 4853171df29c2d8286b5b3a84038189d18bac308) Conflicts: src/structure.c --- src/structure.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/structure.c b/src/structure.c index a418cf2ee..bdfc385b2 100644 --- a/src/structure.c +++ b/src/structure.c @@ -6780,9 +6780,17 @@ void hqReward(UBYTE losingPlayer, UBYTE rewardPlayer) // BOOL StructIsFactory(STRUCTURE *Struct) { - return Struct->pStructureType->type == REF_FACTORY || - Struct->pStructureType->type == REF_CYBORG_FACTORY || - Struct->pStructureType->type == REF_VTOL_FACTORY; + ASSERT_OR_RETURN(false, Struct != NULL, "Invalid structure!"); + ASSERT_OR_RETURN(false, Struct->pStructureType != NULL, "Invalid structureType!"); + + if( (Struct->pStructureType->type == REF_FACTORY) || + (Struct->pStructureType->type == REF_CYBORG_FACTORY) || + (Struct->pStructureType->type == REF_VTOL_FACTORY) ) + { + return true; + } + + return false; }