]> granicus.if.org Git - nethack/commitdiff
get_cost_of_shop_item() crash
authorPatR <rankin@nethack.org>
Sun, 6 Jan 2019 10:36:41 +0000 (02:36 -0800)
committerPatR <rankin@nethack.org>
Sun, 6 Jan 2019 10:36:41 +0000 (02:36 -0800)
More shop price determination fallout.  After the most recent change
to get_cost_of_shop_item(), using ':' inside an engulfer carrying at
least one item while inside a shop would try to follow the item's
obj->ocontainer back-link and crash when that led to the engulfing
monster rather than to a container.

doc/fixes36.2
src/invent.c
src/shk.c

index 8f6f39321bc19eabd7b8d3badd13e5004149a04d..92c65117b1d3c73831479ed25197624119753259 100644 (file)
@@ -1,4 +1,4 @@
-$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.224 $ $NHDT-Date: 1546687293 2019/01/05 11:21:33 $
+$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.225 $ $NHDT-Date: 1546770987 2019/01/06 10:36:27 $
 
 This fixes36.2 file is here to capture information about updates in the 3.6.x
 lineage following the release of 3.6.1 in April 2018. Please note, however,
@@ -378,6 +378,8 @@ when in a shop and using ':' to look inside a container in inventory, items
 when in a shop and using ':' to look inside a container on shop floor, items
        that shopkeeper didn't care about weren't shown as "no charge" unless
        the hero owned the container
+when engulfed while in a shop, dropping an item into the engulfer and then
+       using ':' to look at current location could cause a crash
 tty: turn off an optimization that is the suspected cause of Windows reported
        partial status lines following level changes
 tty: ensure that current status fields are always copied to prior status
index c28a2120d3ceef24d49124f3d0db70fba692b33c..9e32a436341c43dc5e4e1157ebf9dfa584d205ac 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 invent.c        $NHDT-Date: 1546467443 2019/01/02 22:17:23 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.248 $ */
+/* NetHack 3.6 invent.c        $NHDT-Date: 1546770988 2019/01/06 10:36:28 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.249 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -2938,7 +2938,8 @@ boolean nested, /* include contents of any nested containers */
     long count = 0L;
 
     if (!everything) {
-        for (topc = container; topc->ocontainer; topc = topc->ocontainer)
+        for (topc = container; topc->where == OBJ_CONTAINED;
+             topc = topc->ocontainer)
             continue;
         if (topc->where == OBJ_FLOOR) {
             xchar x, y;
index 70e5158a4314a0fa537a8e9d9d59adce03dc652d..b3c0a8dd4d369f4739d36cf5826fe611c76fdd75 100644 (file)
--- a/src/shk.c
+++ b/src/shk.c
@@ -1,4 +1,4 @@
-/* NetHack 3.6 shk.c   $NHDT-Date: 1546687294 2019/01/05 11:21:34 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.151 $ */
+/* NetHack 3.6 shk.c   $NHDT-Date: 1546770990 2019/01/06 10:36:30 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.152 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1991,7 +1991,7 @@ int *nochrg; /* alternate return value: 1: no charge, 0: shop owned,        */
         && get_obj_location(obj, &x, &y, CONTAINED_TOO)
         && *in_rooms(x, y, SHOPBASE) == *u.ushops
         && (shkp = shop_keeper(inside_shop(x, y))) != 0 && inhishop(shkp)) {
-        for (top = obj; top->ocontainer; top = top->ocontainer)
+        for (top = obj; top->where == OBJ_CONTAINED; top = top->ocontainer)
             continue;
         *nochrg = (top->where == OBJ_FLOOR && obj->no_charge);