Fix possible array bound violation for insanely long dives

When we calculate the interval for the tick-marks for the dive, we need
to limit 'i' to be within the size of the array.  The code does that
with a "i < 8" check, but the fact is, we must never increment past the
last entry, which is 7 (the size of the array is 8, but the last valid
index is 7).

This only happens for unrealistically long dives.  Which you can trigger
either by inputting insane values for a manually created dive, or by
merging two dives that are consecutive, but not close to each other
time-wise (eg on different days ;)

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2012-11-11 14:51:33 +01:00 committed by Dirk Hohndel
parent 96fb31bc01
commit 80485114ba

View file

@ -910,7 +910,7 @@ static void plot_depth_profile(struct graphics_context *gc, struct plot_info *pi
* we double the interval if this still doesn't get us to 12 or fewer
* time markers */
i = 0;
while (maxtime / increments[i] > 12 && i < 8)
while (maxtime / increments[i] > 12 && i < 7)
i++;
incr = increments[i];
while (maxtime / incr > 12)