]> granicus.if.org Git - nethack/commitdiff
Add null-check on repairable_damage()
authorSHIRAKATA Kentaro <argrath@ub32.org>
Tue, 8 Feb 2022 15:17:16 +0000 (00:17 +0900)
committerSHIRAKATA Kentaro <argrath@ub32.org>
Tue, 8 Feb 2022 20:54:27 +0000 (05:54 +0900)
Add null-check of dam before its first use.

src/shk.c

index d1652970395e73da0024a40ed5ee0b91758ec9ca..3175eb60eed56e6ad3da643b6e7ed2c96501627b 100644 (file)
--- a/src/shk.c
+++ b/src/shk.c
@@ -3525,13 +3525,16 @@ shk_impaired(struct monst *shkp)
 static boolean
 repairable_damage(struct damage *dam, struct monst *shkp)
 {
-    xchar x = dam->place.x, y = dam->place.y;
+    xchar xy;
     struct trap* ttmp;
     struct monst *mtmp;
 
     if (!dam || shk_impaired(shkp))
         return FALSE;
 
+    x = dam->place.x;
+    y = dam->place.y;
+
     /* too soon to fix it? */
     if ((g.moves - dam->when) < REPAIR_DELAY)
         return FALSE;