From bbc46d0eefbd33e9a90587dffa991766ac34dace Mon Sep 17 00:00:00 2001 From: Allanis Date: Sat, 6 Jul 2013 15:29:01 +0100 Subject: [PATCH] [Fix] Segfault when player dies. --- src/weapon.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/weapon.c b/src/weapon.c index b9b1bd5..329fe87 100644 --- a/src/weapon.c +++ b/src/weapon.c @@ -13,7 +13,7 @@ #include "spfx.h" #include "weapon.h" -#define weapon_isSmart(w) (w->think) +#define weapon_isSmart(w) (w->think != NULL) #define VOICE_PRIORITY_BOLT 10 /* Default. */ #define VOICE_PRIORITY_AMMO 8 /* Higher. */ @@ -263,6 +263,8 @@ static void weapon_update(Weapon* w, const double dt, WeaponLayer layer) { gl_getSpriteFromDir(&wsx, &wsy, gfx, w->solid->dir); for(i = 0; i < pilot_nstack; i++) { + /* Check for player to exist. */ + if((i == 0) && (player == NULL)) continue; psx = pilot_stack[i]->tsx; psy = pilot_stack[i]->tsy;