From 74a64b1647329cd849eaa041d59461f1129b83c8 Mon Sep 17 00:00:00 2001 From: janne-hmp Date: Sat, 10 Jul 2021 11:47:22 +0300 Subject: [PATCH] Fixed two index out of bounds errors when eating standard eggs. Their corpsenm is -1, resulting in index being out of bounds in mons array. --- src/eat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/eat.c b/src/eat.c index 27dd5f7e3..63bd7e359 100644 --- a/src/eat.c +++ b/src/eat.c @@ -2252,7 +2252,7 @@ fpostfx(struct obj *otmp) heal_legs(0); break; case EGG: - if (flesh_petrifies(&mons[otmp->corpsenm])) { + if (otmp->corpsenm >= LOW_PM && flesh_petrifies(&mons[otmp->corpsenm])) { if (!Stone_resistance && !(poly_when_stoned(g.youmonst.data) && polymon(PM_STONE_GOLEM))) { @@ -2334,7 +2334,7 @@ edibility_prompts(struct obj *otmp) if (cadaver || otmp->otyp == EGG || otmp->otyp == TIN) { /* These checks must match those in eatcorpse() */ - stoneorslime = (flesh_petrifies(&mons[mnum]) && !Stone_resistance + stoneorslime = (mnum >= LOW_PM && flesh_petrifies(&mons[mnum]) && !Stone_resistance && !poly_when_stoned(g.youmonst.data)); if (mnum == PM_GREEN_SLIME || otmp->otyp == GLOB_OF_GREEN_SLIME)