From e1b01a5d7c7535600224a29d89df3e6e188a04ae Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sat, 4 Feb 2023 17:48:53 +0200 Subject: [PATCH] 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. --- src/objnam.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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));