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]'
This commit is contained in:
Mika Kuoppala
2024-01-10 17:26:38 +02:00
parent 3f3d5b7bda
commit 91781ef0a6

View File

@@ -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 */