]> granicus.if.org Git - nethack/commitdiff
Impossible instead of segfault in cursed
authorPasi Kallinen <paxed@alt.org>
Mon, 12 Dec 2016 15:42:02 +0000 (17:42 +0200)
committerPasi Kallinen <paxed@alt.org>
Mon, 12 Dec 2016 15:42:06 +0000 (17:42 +0200)
While fuzz testing, I've seen segfault a handful of times in here,
coming from do_takeoff(). Looks like context.takeoff.what is stale,
having WORN_BLINDF, but we're not wearing the blindfold anymore.

Haven't been able to trace it down yet, so guard it with impossible.

src/do_wear.c

index e588e5413967d4070d81c83f8be2056ec130fee6..15f00bbee2fca5a59120176960908e1fd2bf795a 100644 (file)
@@ -1484,6 +1484,10 @@ int
 cursed(otmp)
 register struct obj *otmp;
 {
+    if (!otmp) {
+        impossible("cursed without otmp");
+        return 0;
+    }
     /* Curses, like chickens, come home to roost. */
     if ((otmp == uwep) ? welded(otmp) : (int) otmp->cursed) {
         boolean use_plural = (is_boots(otmp) || is_gloves(otmp)