From da9ba25067c08190d9a915bb3255529d26be6b3c Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Tue, 27 Sep 2011 16:08:55 +0000 Subject: [PATCH] Add a sanity check to prevent a potential crash --- src/game/baseq2/g_ai.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/game/baseq2/g_ai.c b/src/game/baseq2/g_ai.c index 4be78d31..1d2fff23 100644 --- a/src/game/baseq2/g_ai.c +++ b/src/game/baseq2/g_ai.c @@ -308,6 +308,11 @@ visible(edict_t *self, edict_t *other) vec3_t spot2; trace_t trace; + if (!self || !other) + { + return false; + } + VectorCopy(self->s.origin, spot1); spot1[2] += self->viewheight; VectorCopy(other->s.origin, spot2); @@ -333,7 +338,7 @@ infront(edict_t *self, edict_t *other) float dot; vec3_t forward; - if ((self == NULL) || (other == NULL)) + if (!self || !other) { return false; }