]> granicus.if.org Git - nethack/commitdiff
charging scroll fix (trunk only)
authornethack.rankin <nethack.rankin>
Thu, 8 Jun 2006 05:05:33 +0000 (05:05 +0000)
committernethack.rankin <nethack.rankin>
Thu, 8 Jun 2006 05:05:33 +0000 (05:05 +0000)
     A while back some code ended up in the wrong order, resulting in null
pointer dereference when reading a not-yet-discovered scroll of charging.

src/read.c

index 4cd0af8fbce89c448ac85f088450caa95a693037..fe498b4806dc40e871a3a1b1417b39ce6873477b 100644 (file)
@@ -1179,15 +1179,15 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
                    break;
                }
                /* known = TRUE; -- handled inline here */
+               if (!already_known) {
+                   pline("This is a charging scroll.");
+                   learnscroll(sobj);
+               }
                /* use it up now to prevent it from showing in the
                   getobj picklist because the "disappears" message
                   was already delivered */
                useup(sobj);
                sobj = 0;       /* it's gone */
-               if (!already_known) {
-                   pline("This is a charging scroll.");
-                   learnscroll(sobj);
-               }
                otmp = getobj(all_count, "charge");
                if (otmp) recharge(otmp, scursed ? -1 : sblessed ? 1 : 0);
                break;