From 2e35f04c1daf1e913c58e769e64854bf51af6208 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sun, 24 Dec 2023 00:19:41 -0500 Subject: [PATCH] static analyzer bit for invent.c src/invent.c(4882): warning: Dereferencing NULL pointer '((otmp))->oextra'. --- src/invent.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/invent.c b/src/invent.c index 167eee0cf..e10e1eaf1 100644 --- a/src/invent.c +++ b/src/invent.c @@ -4880,7 +4880,9 @@ mergable( if ((objnamelth != otmpnamelth && ((objnamelth && otmpnamelth) || obj->otyp == CORPSE)) || (objnamelth && otmpnamelth - && strncmp(ONAME(obj), ONAME(otmp), objnamelth))) + /* safe_oname could have returned ptr to "", verify before deref */ + && has_oname(obj) && has_oname(otmp) + && strncmp(ONAME(obj), ONAME(otmp), objnamelth))) return FALSE; /* if one has an attached mail command, other must have same command */