fix #K4091 - losexp() assert(u.ulevel < 30) fail

Previously reported via github pull request #1188 as an out of bounds
access to u.uhpinc[], followed by issue #1189 when it was closed, the
backtrace accompanying new assertion failure provided more information
that led to figuring out the problem.

Only mattered for the debug fuzzer; wouldn't happen in regular play.

When the hero dies during fuzzing, the fuzzer sometimes restores lost
levels via blessed potion of restore ability.  If that happened to a
hero who died by being life-drained while at level 1 then losexp()'s
assumption that life-saved hero was still level 1 got violated.  If
levels had been lost all the way down from a peak of 30, restoration
to u.ulevel==30 resulted in invalid array indexing into u.uhpinc[],
then failure of 'assert(u.ulevel >= 0 && u.ulevel < MAXULEV)' which
was added to avoid that.

Pull request #1188 and issue #1189 are already closed, but they hadn't
actually been solved yet.

Fixes #1188
Fixes #1189
This commit is contained in:
PatR
2024-01-24 14:31:26 -08:00
parent c2ddd2a7c2
commit 90d515b6ab
2 changed files with 12 additions and 4 deletions

View File

@@ -1847,6 +1847,10 @@ stacked pair of potions of healing in supply chest weighed same as one potion;
immediately followed a decrease message when the potion got used up
bounds checking for object name formatting inadvertently introduced a change
that hid BUC prefix for charged rings
debug fuzzer was triggering out of bounds array access in loseexp() if
life-saving at level 1 used blessed restore ability to regain lost
levels and restored those all the way to level 30; introducing an
assert(u.ulevel < MAXULEV) changed bounds issue to assertion failure
Fixes to 3.7.0-x Platform and/or Interface Problems Exposed Via git Repository