]> granicus.if.org Git - nethack/commitdiff
add null-check on fill_special_room()
authorSHIRAKATA Kentaro <argrath@ub32.org>
Tue, 8 Feb 2022 08:20:50 +0000 (17:20 +0900)
committerSHIRAKATA Kentaro <argrath@ub32.org>
Tue, 8 Feb 2022 08:20:50 +0000 (17:20 +0900)
Add null-check of croom before its first use.

src/sp_lev.c

index 7efbb091a3a12596bf5d60742aa9b2c669af54a8..f2ee11783dc4a0f80ba63b7c1004d36fc62b7287 100644 (file)
@@ -2588,6 +2588,9 @@ fill_special_room(struct mkroom* croom)
 {
     int i;
 
+    if (!croom)
+        return;
+
     /* First recurse into subrooms. We don't want to block an ordinary room with
      * a special subroom from having the subroom filled, or an unfilled outer
      * room preventing a special subroom from being filled. */
@@ -2595,7 +2598,7 @@ fill_special_room(struct mkroom* croom)
         fill_special_room(croom->sbrooms[i]);
     }
 
-    if (!croom || croom->rtype == OROOM || croom->rtype == THEMEROOM
+    if (croom->rtype == OROOM || croom->rtype == THEMEROOM
         || croom->needfill == FILL_NONE)
         return;