fit git issue #960 - out-of-bounds array access

Issue reported by argrath:  if getoptstr() executed its loop to
find the latest phase that set a role/race/gender/alignment option
value, the first iteration of the loop would use an index that's
out of bounds.

The code in question is wrong but happens to not be used, so the
out of bounds access doesn't occur.  Fix the value for the first
iteration in case the offending code eventually gets used.

Fixes #960
This commit is contained in:
PatR
2023-01-22 01:43:20 -08:00
parent 1f9cb8250b
commit 550845c3a1

View File

@@ -617,7 +617,7 @@ getoptstr(int optidx, int ophase)
/* find non-Null, in order optvals[][play_opt], [cmdline_opt],
[environ_opt], [rc_file_opt], [syscf_opt], [builtin_opt] */
for (phase = num_opt_phases; phase >= 0; --phase)
for (phase = num_opt_phases - 1; phase >= 0; --phase)
if (roleoptvals[roleoptindx][phase]) {
ophase = phase;
break;