]> granicus.if.org Git - nethack/commitdiff
move null-check on savelev()
authorSHIRAKATA Kentaro <argrath@ub32.org>
Mon, 21 Mar 2022 11:31:41 +0000 (20:31 +0900)
committerSHIRAKATA Kentaro <argrath@ub32.org>
Wed, 23 Mar 2022 19:16:16 +0000 (04:16 +0900)
Move null-check of ttmp before its first use.

src/trap.c

index 406890a9a7ac968bde7f090615106dfc3b8d1e77..012ab4b71af552a26933310e75bc24c6e265476e 100644 (file)
@@ -3025,11 +3025,14 @@ find_random_launch_coord(struct trap *ttmp, coord *cc)
     int mindist = 4;
     int trycount = 0;
     xchar dx, dy;
-    xchar x = ttmp->tx, y = ttmp->ty;
+    xchar xy;
 
     if (!ttmp || !cc)
         return FALSE;
 
+    x = ttmp->tx;
+    y = ttmp->ty;
+
     bcc.x = ttmp->tx + g.launchplace.x;
     bcc.y = ttmp->ty + g.launchplace.y;
     if (isok(bcc.x, bcc.y) && linedup(ttmp->tx, ttmp->ty, bcc.x, bcc.y, 1)) {