fix use-after-free bug in curses shutdown

A year ago a use-free-bug was reported for curses.  I don't use ASAN
so haven't reproduced it, but I think this should fix it.

If the RIP window is deleted after the map window has gone away, the
code from commit 5e572d3d5f (post 3.6.7)
would execute and access the internals of the deleted map window.
This commit is contained in:
PatR
2026-04-11 01:02:42 -07:00
parent 45b01cdb9a
commit b264e17cf2

View File

@@ -224,6 +224,10 @@ curses_destroy_win(WINDOW *win)
delwin(win);
if (win == activemenu)
activemenu = NULL;
/* during shutdown, RIP window could still be active after mapwin goes
away; so, avoid 'if (mapwin)' above when deleting RIP window later */
if (win == mapwin)
win = mapwin = NULL;
curses_refresh_nethack_windows();
nhUse(dummyht);
}