From e9e11f160501e2dbd60351968a496e9c4bed5e6d Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sat, 21 Apr 2018 14:07:22 -0500 Subject: [PATCH] Fix possible bot goal state NULL pointer dereference --- code/botlib/be_ai_goal.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/botlib/be_ai_goal.c b/code/botlib/be_ai_goal.c index 0bbc6a5e..4df36887 100644 --- a/code/botlib/be_ai_goal.c +++ b/code/botlib/be_ai_goal.c @@ -227,6 +227,9 @@ void BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child) p2 = BotGoalStateFromHandle(parent2); c = BotGoalStateFromHandle(child); + if (!p1 || !p2 || !c) + return; + InterbreedWeightConfigs(p1->itemweightconfig, p2->itemweightconfig, c->itemweightconfig); } //end of the function BotInterbreedingGoalFuzzyLogic @@ -241,7 +244,7 @@ void BotSaveGoalFuzzyLogic(int goalstate, char *filename) //bot_goalstate_t *gs; //gs = BotGoalStateFromHandle(goalstate); - + //if (!gs) return; //WriteWeightConfig(filename, gs->itemweightconfig); } //end of the function BotSaveGoalFuzzyLogic //=========================================================================== @@ -255,7 +258,7 @@ void BotMutateGoalFuzzyLogic(int goalstate, float range) bot_goalstate_t *gs; gs = BotGoalStateFromHandle(goalstate); - + if (!gs) return; EvolveWeightConfig(gs->itemweightconfig); } //end of the function BotMutateGoalFuzzyLogic //===========================================================================