suit_simple_name()

Unlike cloak_simple_name() and helm_simple_name(), suit_simple_name()
wasn't guarding against Null.  Current usage never trips up against
that, but when I added a new use in doseduce() [pending], it caused
a crash.
This commit is contained in:
PatR
2018-08-03 20:07:21 -07:00
parent fedc093f23
commit 78a4edcc0f
+4 -2
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 objnam.c $NHDT-Date: 1525012618 2018/04/29 14:36:58 $ $NHDT-Branch: master $:$NHDT-Revision: 1.202 $ */ /* NetHack 3.6 objnam.c $NHDT-Date: 1533352036 2018/08/04 03:07:16 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.206 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -3978,6 +3978,7 @@ struct obj *suit;
{ {
const char *suitnm, *esuitp; const char *suitnm, *esuitp;
if (suit) {
if (Is_dragon_mail(suit)) if (Is_dragon_mail(suit))
return "dragon mail"; /* <color> dragon scale mail */ return "dragon mail"; /* <color> dragon scale mail */
else if (Is_dragon_scales(suit)) else if (Is_dragon_scales(suit))
@@ -3988,7 +3989,8 @@ struct obj *suit;
return "mail"; /* most suits fall into this category */ return "mail"; /* most suits fall into this category */
else if (strlen(suitnm) > 7 && !strcmp(esuitp - 7, " jacket")) else if (strlen(suitnm) > 7 && !strcmp(esuitp - 7, " jacket"))
return "jacket"; /* leather jacket */ return "jacket"; /* leather jacket */
/* suit is lame but armor is ambiguous and body armor is absurd */ }
/* "suit" is lame but "armor" is ambiguous and "body armor" is absurd */
return "suit"; return "suit";
} }