From 8f579ba9accd39ae93c17e589e942cebf1ee7848 Mon Sep 17 00:00:00 2001
From: Allanis <allanis@saracraft.net>
Date: Sat, 17 May 2014 13:15:08 +0100
Subject: [PATCH] [Fix] Fixed segfault in volatile nebulae.

---
 src/pilot.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/pilot.c b/src/pilot.c
index fd8fb69..ee4bb28 100644
--- a/src/pilot.c
+++ b/src/pilot.c
@@ -461,11 +461,12 @@ void pilot_hit(Pilot* p, const Solid* w, const unsigned int shooter,
     }
   }
 
-  /* Knock back effect is dependent on both damage and mass of the weapon. */
-  /* should probably turn it into a partial conservative collision.. */
-  vect_cadd(&p->solid->vel,
-      knockback * (w->vel.x * (dam_mod/6. + w->mass/p->solid->mass/6.)),
-      knockback * (w->vel.y * (dam_mod/6. + w->mass/p->solid->mass/6.)));
+  if(w != NULL)
+    /* Knock back effect is dependent on both damage and mass of the weapon. */
+    /* should probably turn it into a partial conservative collision.. */
+    vect_cadd(&p->solid->vel,
+        knockback * (w->vel.x * (dam_mod/6. + w->mass/p->solid->mass/6.)),
+        knockback * (w->vel.y * (dam_mod/6. + w->mass/p->solid->mass/6.)));
 }
 
 /**