]> granicus.if.org Git - nethack/commit
resuming interrupted 'A' command
authornethack.rankin <nethack.rankin>
Sat, 15 Nov 2003 10:25:09 +0000 (10:25 +0000)
committernethack.rankin <nethack.rankin>
Sat, 15 Nov 2003 10:25:09 +0000 (10:25 +0000)
commite989ae0b96c12fc81939e0db35debff108e458bb
treeae75b5457a1cc806e39082aab396a93e7a3d98e3
parent23d3a146d967786f0957dcf1a862604e10c27433
resuming interrupted 'A' command

[ Caveat:  compiles ok on branch code but only play tested on trunk code;
  the do_wear.c diff is a lot different between the two variants and the
  trunk one includes some whitespace cleanup. ]

     <email deleted> reported that having a spellcasting monster
destroy some armor while you're in the midst of using 'A' to take that
armor off would result in a crash.  The problem was actually more
widespread than that:  having a nymph steal worn items (accessories as
well as armor), or a succubus remove them, or being interrupted by monster
activity and then reading a scroll of destroy armor prior to resuming 'A'
could all produce a similar crash.  'A' relied on stale context and could
attempt to manipulate an equipment slot which had become empty, ultimately
leading to an attempt to dereference a null pointer.

     The 'R' command didn't have this problem since any accessory gets
removed immediately.  The 'T' command already had handling for this:
there's only one item to deal with and multi-turn take off only applies
to some of the slots; the donning() check followed by cancel_don() took
care of those.  Only 'A' was vulnerable to the problem and it wouldn't
necessarily need to be interrupted and resumed; loss of the current
multi-turn item or any pending item would be enough--but I'm not sure
whether such item loss could occur without also interrupting the current
activity, so resumption of previous 'A' was probably a requirement for
triggering the crash.

     This makes shield and shirt handling be similar to other types of
armor instead of relying on the fact that none of them need to have any
attribute adjustments when put on or taken off.  However, there are
still assumptions (the `cancelled_don' stuff) that some slots don't have
any eligible items requiring more than a single turn to use; that should
probably be changed.
doc/fixes34.3
include/extern.h
src/do_wear.c
src/steal.c