From: PatR Date: Mon, 16 May 2022 16:41:21 +0000 (-0700) Subject: fix segfault with #therecmdmenu X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b562c8ac8929d598409a271994fb7a7da0e12698;p=nethack fix segfault with #therecmdmenu The change to add a menu choice for naming an adjacent monster via \#therecmdmenu was unintentionally requiring that the monster have monst->mextra. So it worked on pets (regardless of whether they were already named) because they have mextra for 'edog' extension, but not on the majority of monsters. And when it failed the program would crash with a 'segmentation fault' error. Fix the check for whether a target monster already had a name when deciding to use "name " or "rename " in the menu entry. --- diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index dbe8ff0bb..e36cae270 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1,4 +1,4 @@ -HDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.916 $ $NHDT-Date: 1652689792 2022/05/16 08:29:52 $ +HDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.917 $ $NHDT-Date: 1652719274 2022/05/16 16:41:14 $ General Fixes and Modified Features ----------------------------------- @@ -1215,6 +1215,8 @@ recent changes in removing a dead monster from the map didn't update screen to show objects it dropped; they were present, just not displayed further changes resulted in dead monsters' corpses be placed at <0,0>; reverse the part(s) that cleared stale monst->mx,my +adding name/rename choice to #therecmdmenu caused it to crash when picking an + adjacent unnamed, untame monster curses: 'msg_window' option wasn't functional for curses unless the binary also included tty support diff --git a/src/cmd.c b/src/cmd.c index b4e76919b..99804960c 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 cmd.c $NHDT-Date: 1652637694 2022/05/15 18:01:34 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.563 $ */ +/* NetHack 3.7 cmd.c $NHDT-Date: 1652719274 2022/05/16 16:41:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.564 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -4764,7 +4764,7 @@ there_cmd_menu_next2u( } if (mtmp) { Sprintf(buf, "%s %s", - !MGIVENNAME(mtmp) ? "Name" : "Rename", + !has_mgivenname(mtmp) ? "Name" : "Rename", mon_nam(mtmp)); mcmd_addmenu(win, MCMD_NAME, buf), ++K; }