]> granicus.if.org Git - nethack/commitdiff
fix uarmh null pointer dereference
authornhmall <nhmall@nethack.org>
Tue, 24 Sep 2019 16:32:58 +0000 (12:32 -0400)
committernhmall <nhmall@nethack.org>
Tue, 24 Sep 2019 16:32:58 +0000 (12:32 -0400)
uarmh null pointer dereference if a helm of opposite alignment came off due
to being polymorphed

fixes #225

doc/fixes36.3
src/do_wear.c

index 86b1df33e5919caaa155644a65f8474ac2cd97c9..247c5410a853ac4f1b93c2f34d01bd48fd75d6a8 100644 (file)
@@ -152,6 +152,8 @@ zapping self with wand of opening or spell of knock to escape from a pit trap
 wielded aklys that returned to hero when thrown while inside an engulfer left
        a stale 'thrownobj' pointer that triggered "add_to_minv: obj not free"
        panic if same weapon killed any engulfer via melee from inside
+uarmh null pointer dereference if a helm of opposite alignment came off due 
+       to being polymorphed
 
 
 Fixes to Post-3.6.2 Problems that Were Exposed Via git Repository
index 6c99c1a5d3598797e7f01cdc98f18e47659423bb..78262cba0ce561202f0589a8ac67742132a1b28a 100644 (file)
@@ -392,6 +392,7 @@ Helmet_on(VOID_ARGS)
         makeknown(uarmh->otyp);
         break;
     case HELM_OF_OPPOSITE_ALIGNMENT:
+        uarmh->known = 1; /* do this here because uarmh could get cleared */
         /* changing alignment can toggle off active artifact
            properties, including levitation; uarmh could get
            dropped or destroyed here */
@@ -427,7 +428,9 @@ Helmet_on(VOID_ARGS)
     default:
         impossible(unknown_type, c_helmet, uarmh->otyp);
     }
-    uarmh->known = 1; /* helmet's +/- evident because of status line AC */
+    /* uarmh could be zero due to uchangealign() */
+    if (uarmh)
+        uarmh->known = 1; /* helmet's +/- evident because of status line AC */
     return 0;
 }