From: Pasi Kallinen Date: Sat, 4 Feb 2023 15:48:53 +0000 (+0200) Subject: Fix segfault when farlooking monster under generic object X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e1b01a5d7c7535600224a29d89df3e6e188a04ae;p=nethack Fix segfault when farlooking monster under generic object A detected cave spider was hiding under a generic spellbook object; farlooking at it produced a segfault. OBJ_NAME is null for the generic objects, so don't try to strcmp it. --- diff --git a/src/objnam.c b/src/objnam.c index 960247ac3..707d022f4 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -2139,7 +2139,7 @@ ansimpleoname(struct obj* obj) any `known' and `dknown' checking necessary) */ if (otyp == FAKE_AMULET_OF_YENDOR) otyp = AMULET_OF_YENDOR; - if (objects[otyp].oc_unique + if (objects[otyp].oc_unique && OBJ_NAME(objects[otyp]) && !strcmp(simpleoname, OBJ_NAME(objects[otyp]))) { /* the() will allocate another obuf[]; we want to avoid using two */ Strcpy(simpleoname, obufp = the(simpleoname));