From 190d840d2adf9dbcc585f9f77ed19d82b8629ea3 Mon Sep 17 00:00:00 2001 From: SHIRAKATA Kentaro Date: Wed, 9 Feb 2022 17:40:33 +0900 Subject: [PATCH] remove unnecessary null-check on gold_detect() `sobj` here is always non-null, otherwise it leads segv at earlier code. --- src/detect.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/detect.c b/src/detect.c index 4171786c2..ae3390c0e 100644 --- a/src/detect.c +++ b/src/detect.c @@ -367,26 +367,24 @@ gold_detect(struct obj *sobj) if (!gk.known) { /* no gold found on floor or monster's inventory. adjust message if you have gold in your inventory */ - if (sobj) { - char buf[BUFSZ]; + char buf[BUFSZ]; - if (gy.youmonst.data == &mons[PM_GOLD_GOLEM]) - Sprintf(buf, "You feel like a million %s!", currency(2L)); - else if (money_cnt(gi.invent) || hidden_gold(TRUE)) - Strcpy(buf, - "You feel worried about your future financial situation."); - else if (steedgold) - Sprintf(buf, "You feel interested in %s financial situation.", - s_suffix(x_monnam(u.usteed, - u.usteed->mtame ? ARTICLE_YOUR - : ARTICLE_THE, - (char *) 0, - SUPPRESS_SADDLE, FALSE))); - else - Strcpy(buf, "You feel materially poor."); + if (gy.youmonst.data == &mons[PM_GOLD_GOLEM]) + Sprintf(buf, "You feel like a million %s!", currency(2L)); + else if (money_cnt(gi.invent) || hidden_gold(TRUE)) + Strcpy(buf, + "You feel worried about your future financial situation."); + else if (steedgold) + Sprintf(buf, "You feel interested in %s financial situation.", + s_suffix(x_monnam(u.usteed, + u.usteed->mtame ? ARTICLE_YOUR + : ARTICLE_THE, + (char *) 0, + SUPPRESS_SADDLE, FALSE))); + else + Strcpy(buf, "You feel materially poor."); - strange_feeling(sobj, buf); - } + strange_feeling(sobj, buf); return 1; } /* only under me - no separate display required */