From 91781ef0a6ebdf3fbbbf3e4182a71029ca32df7a Mon Sep 17 00:00:00 2001 From: Mika Kuoppala Date: Wed, 10 Jan 2024 17:26:38 +0200 Subject: [PATCH] dothrow: Check for LOW_PM before accessing mon array on toss_up() when checking for touch_petrifies, add a check for corpsenm >= LOW_PM as EGG can be without corpse reference. This prevents: dothrow.c:1266:29: runtime error: index -1 out of bounds for type 'permonst [384]' --- src/dothrow.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dothrow.c b/src/dothrow.c index 3fa52381e..23d359843 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -1263,6 +1263,7 @@ toss_up(struct obj *obj, boolean hitsroof) const char *action; int otyp = obj->otyp; boolean petrifier = ((otyp == EGG || otyp == CORPSE) + && obj->corpsenm >= LOW_PM && touch_petrifies(&mons[obj->corpsenm])); /* note: obj->quan == 1 */