out of bounds memory access during zap bounce

Apply the diff from entrez to deal with out of array bounds access by
wand or spell zap when deciding whether to bounce if that zap reached
the extreme edge of the map (not just the edge of the portion of the
map in use by current level).
This commit is contained in:
PatR
2022-07-14 15:17:30 -07:00
parent b14b830b49
commit 5ddf8c9815
2 changed files with 11 additions and 13 deletions

View File

@@ -4477,9 +4477,9 @@ dobuzz(
boolean fireball;
make_bounce:
bchance = (levl[sx][sy].typ == STONE) ? 10
: (In_mines(&u.uz) && IS_WALL(levl[sx][sy].typ)) ? 20
: 75;
bchance = (!isok(sx, sy) || levl[sx][sy].typ == STONE) ? 10
: (In_mines(&u.uz) && IS_WALL(levl[sx][sy].typ)) ? 20
: 75;
bounce = 0;
fireball = (type == ZT_SPELL(ZT_FIRE));
if ((--range > 0 && isok(lsx, lsy) && cansee(lsx, lsy))
@@ -4532,16 +4532,12 @@ dobuzz(
if (type == ZT_SPELL(ZT_FIRE))
explode(sx, sy, type, d(12, 6), 0, EXPL_FIERY);
if (shopdamage)
pay_for_damage(abstype == ZT_FIRE
? "burn away"
: abstype == ZT_COLD
? "shatter"
/* "damage" indicates wall rather than door */
: abstype == ZT_ACID
? "damage"
: abstype == ZT_DEATH
? "disintegrate"
: "destroy",
pay_for_damage(abstype == ZT_FIRE ? "burn away"
: abstype == ZT_COLD ? "shatter"
/* "damage" indicates wall rather than door */
: abstype == ZT_ACID ? "damage"
: abstype == ZT_DEATH ? "disintegrate"
: "destroy",
FALSE);
g.bhitpos = save_bhitpos;
}