From: nhmall Date: Tue, 15 Jun 2021 19:49:31 +0000 (-0400) Subject: null pointer dereference in do_name.c X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5ac913e0353f3b3204d6b6a95fc65c7551f48372;p=nethack null pointer dereference in do_name.c fixes #534 --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 8320a3f99..3bb4ba3bf 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -713,6 +713,8 @@ enlightenment/disclosure when wielding two weapons with two-weap skill higher than secondary weapon's skill had "with" duplicated in the feedback corpse of monster with gender specific names (king vs queen and so forth) was always described by the neutral name (ruler and such) +prevent obj_pmname() from calling mon_pmname(&monst) when monst->data is null + to prevent a null pointer dereference curses: 'msg_window' option wasn't functional for curses unless the binary also included tty support diff --git a/src/do_name.c b/src/do_name.c index 9c17550ae..4ffc9b266 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -2098,7 +2098,7 @@ mon_pmname(struct monst *mon) const char * obj_pmname(struct obj *obj) { - if (has_omonst(obj)) + if (has_omonst(obj) && OMONST(obj)->data) return mon_pmname(OMONST(obj)); if ((obj->otyp == CORPSE || obj->otyp == STATUE || obj->otyp == FIGURINE)