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.
This commit is contained in:
Pasi Kallinen
2023-02-04 17:48:53 +02:00
parent d515538f21
commit e1b01a5d7c

View File

@@ -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));