]> granicus.if.org Git - nethack/commitdiff
move null-check on savelev()
authorSHIRAKATA Kentaro <argrath@ub32.org>
Tue, 8 Feb 2022 17:39:05 +0000 (02:39 +0900)
committerSHIRAKATA Kentaro <argrath@ub32.org>
Wed, 9 Feb 2022 16:25:13 +0000 (01:25 +0900)
Move null-check of nhfp before its first use.

src/save.c

index b4bec07207ba72424601719a05145d45d4672e02..a21959888767aa850d714c93ba2119fc145f7c89 100644 (file)
@@ -423,6 +423,9 @@ savelev(NHFILE* nhfp, xchar lev)
 #endif
 
     g.program_state.saving++; /* even if current mode is FREEING */
+
+    if (!nhfp)
+        panic("Save on bad file!"); /* impossible */
     /*
      *  Level file contents:
      *    version info (handled by caller);
@@ -449,8 +452,6 @@ savelev(NHFILE* nhfp, xchar lev)
         if (iflags.purge_monsters)
             dmonsfree();
 
-        if (!nhfp)
-            panic("Save on bad file!"); /* impossible */
         if (lev >= 0 && lev <= maxledgerno())
             g.level_info[lev].flags |= VISITED;
         if (nhfp->structlevel)