From 899cca50efbc5b7a51e6e62df376318c4d9a80c4 Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 1 Feb 2024 14:38:28 -0800 Subject: [PATCH] alternate fix for merge_choice() with Null invent merge_choice() doesn't need the address of its list argument, just to return Null if that list is Null. Could have been solved by having its callers check for Null invent and skip the call if necessary but this is simpler. Finishes reverting commit 378648bd9c1e851477d05471f2194d55ee40096c. --- include/extern.h | 2 +- src/invent.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/extern.h b/include/extern.h index 8a8bfce3f..cd0613e01 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1239,7 +1239,7 @@ extern Loot *sortloot(struct obj **, unsigned, boolean, boolean(*)(struct obj *)) NONNULLARG1; extern void unsortloot(Loot **) NONNULLARG1; extern void assigninvlet(struct obj *) NONNULLARG1; -extern struct obj *merge_choice(struct obj *, struct obj *) NONNULLPTRS; +extern struct obj *merge_choice(struct obj *, struct obj *) NONNULLARG2; extern int merged(struct obj **, struct obj **) NONNULLPTRS; extern void addinv_core1(struct obj *) NONNULLARG1; extern void addinv_core2(struct obj *) NONNULLARG1; diff --git a/src/invent.c b/src/invent.c index 20a7cf645..a2e99233e 100644 --- a/src/invent.c +++ b/src/invent.c @@ -786,6 +786,8 @@ merge_choice(struct obj *objlist, struct obj *obj) struct monst *shkp; unsigned save_nocharge; + if (!objlist) /* might be checking 'obj' against empty inventory */ + return (struct obj *) 0; if (obj->otyp == SCR_SCARE_MONSTER) /* punt on these */ return (struct obj *) 0; /* if this is an item on the shop floor, the attributes it will