From: Pasi Kallinen Date: Thu, 19 Jan 2017 17:46:37 +0000 (+0200) Subject: Prevent a segfault with leashed vanished monster X-Git-Tag: NetHack-3.6.1_RC01~533 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=02195d7351978a6d42cfb2d3ea3729d49c2e26a4;p=nethack Prevent a segfault with leashed vanished monster It's apparently somehow possible to have a leash "attached" to a monster not present on the current level. Complain instead of segfaulting. (This is a post-3.6.0 bug) --- diff --git a/src/objnam.c b/src/objnam.c index af3cc2511..bb0c91a44 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -912,8 +912,15 @@ unsigned doname_flags; break; } if (obj->otyp == LEASH && obj->leashmon != 0) { - Sprintf(eos(bp), " (attached to %s)", - a_monnam(find_mid(obj->leashmon, FM_FMON))); + struct monst *mlsh = find_mid(obj->leashmon, FM_FMON); + + if (!mlsh) { + impossible("leashed monster not on this level"); + obj->leashmon = 0; + } else { + Sprintf(eos(bp), " (attached to %s)", + a_monnam(mlsh)); + } break; } if (obj->otyp == CANDELABRUM_OF_INVOCATION) {