bug #823 missing nil checks crasher introduced in r4aa19b21707d
authornemo
Tue, 13 Apr 2021 15:40:11 -0400
changeset 15804 6409d756e9da
parent 15803 b836876d7b2e
child 15806 823cf18be1fc
bug #823 missing nil checks crasher introduced in r4aa19b21707d
hedgewars/uAmmos.pas
--- a/hedgewars/uAmmos.pas	Mon Apr 05 04:05:14 2021 +0200
+++ b/hedgewars/uAmmos.pas	Tue Apr 13 15:40:11 2021 -0400
@@ -406,7 +406,7 @@
     CurWeapon:= GetCurAmmoEntry(Hedgehog);
     OldWeapon:= GetCurAmmoEntry(Hedgehog);
 
-    if (Hedgehog.Gear^.State and gstHHDriven) = 0 then
+    if (Hedgehog.Gear <> nil) and (Hedgehog.Gear^.State and gstHHDriven = 0) then
         Hedgehog.CurAmmoType:= amNothing
     else if (CurWeapon^.Count = 0) then
         SwitchToFirstLegalAmmo(Hedgehog)
@@ -431,7 +431,7 @@
             s:= s + ansistring(' (' + IntToStr(Count) + ')');
         if (Propz and ammoprop_Timerable) <> 0 then
             s:= s + ansistring(', ' + IntToStr(Timer div 1000) + ' ') + trammo[sidSeconds];
-        if (Hedgehog.Gear^.State and gstHHDriven) <> 0 then
+        if (Hedgehog.Gear <> nil) and (Hedgehog.Gear^.State and gstHHDriven <> 0) then
             AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo);
         if (Propz and ammoprop_NeedTarget) <> 0 then
             begin