fix #H9164 - crash during restore when swallowed
Subject was "display crash while in curses mode". Restoring with perm_invent set in config file or NETHACKOPTIONS when the save was made while swallowed (regardless of perm_invent at that time) resulted in a crash when invalid u.ustuck was referenced before restoration had done its pointer fixups. init_nhwindows() is called with perm_invent On; restgamestate() temporarily turns it Off (3.6.2 restore hack); if/when update_inventory() gets called, curses notices that the persistent window has been disabled so it tears down all its windows in order to redraw the screen without that one; docrt() sees non-Null u.ustuck and calls swallowed(); swallowed() tries to use the value of that pointer rather than just Null/non-Null but the value is from the previous game session, not valid for the current session; crash. Make yet another attempt to prevent update_inventory() from being called during restore. curses won't try to redraw and the crash won't happen. But the invalid pointer is still lurking (until an eventual fixup later during restore). An earlier fix for update_inventory() during restore actually handled this problem (for the most common trigger, setworn(), but not in general), so the 3.6.2 behavior is a regression.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 display.c $NHDT-Date: 1560085863 2019/06/09 13:11:03 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.104 $ */
|
||||
/* NetHack 3.6 display.c $NHDT-Date: 1567213890 2019/08/31 01:11:30 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.106 $ */
|
||||
/* Copyright (c) Dean Luick, with acknowledgements to Kevin Darcy */
|
||||
/* and Dave Cohrs, 1990. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -1368,15 +1368,15 @@ docrt()
|
||||
|
||||
if (u.uswallow) {
|
||||
swallowed(1);
|
||||
return;
|
||||
goto post_map;
|
||||
}
|
||||
if (Underwater && !Is_waterlevel(&u.uz)) {
|
||||
under_water(1);
|
||||
return;
|
||||
goto post_map;
|
||||
}
|
||||
if (u.uburied) {
|
||||
under_ground(1);
|
||||
return;
|
||||
goto post_map;
|
||||
}
|
||||
|
||||
/* shut down vision */
|
||||
@@ -1403,6 +1403,8 @@ docrt()
|
||||
/* overlay with monsters */
|
||||
see_monsters();
|
||||
|
||||
post_map:
|
||||
|
||||
/* perm_invent */
|
||||
update_inventory();
|
||||
|
||||
|
||||
22
src/invent.c
22
src/invent.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 invent.c $NHDT-Date: 1562203850 2019/07/04 01:30:50 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.261 $ */
|
||||
/* NetHack 3.6 invent.c $NHDT-Date: 1567213892 2019/08/31 01:11:32 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.262 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Derek S. Ray, 2015. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -2398,6 +2398,26 @@ learn_unseen_invent()
|
||||
update_inventory();
|
||||
}
|
||||
|
||||
/* persistent inventory window is maintained by interface code;
|
||||
'update_inventory' used to be a macro for
|
||||
(*windowprocs.win_update_inventory) but the restore hackery
|
||||
was getting out of hand; this is now a central call point */
|
||||
void
|
||||
update_inventory()
|
||||
{
|
||||
if (restoring)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Ought to check (windowprocs.wincap2 & WC2_PERM_INVENT) here....
|
||||
*
|
||||
* We currently don't skip this call when iflags.perm_invent is False
|
||||
* because curses uses that to disable a previous perm_invent window
|
||||
* (after toggle via 'O'; perhaps the options code should handle that).
|
||||
*/
|
||||
(*windowprocs.win_update_inventory)();
|
||||
}
|
||||
|
||||
/* should of course only be called for things in invent */
|
||||
STATIC_OVL char
|
||||
obj_to_let(obj)
|
||||
|
||||
Reference in New Issue
Block a user