bug #823 missing nil checks crasher introduced in r4aa19b21707d 1.0.0
authornemo
Tue, 13 Apr 2021 15:40:11 -0400
branch1.0.0
changeset 15805 23e16f33b528
parent 15801 dbed9069ed50
child 15838 b0fe8c8d0bb5
bug #823 missing nil checks crasher introduced in r4aa19b21707d
hedgewars/uAmmos.pas
--- a/hedgewars/uAmmos.pas	Thu Jun 04 12:33:24 2020 +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