mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Don't walk back in time
A strange and buggy dive where time goes backwards (right now easy to create with the dive plan editor) can cause us to run out of plot info elements. This prevents that from causing memory corruption by refusing to go back in time. Reported-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
c2bc6633ec
commit
7e1f0d243b
1 changed files with 4 additions and 0 deletions
|
@ -1640,6 +1640,10 @@ static struct plot_data *populate_plot_entries(struct dive *dive, struct divecom
|
|||
|
||||
/* Add intermediate plot entries if required */
|
||||
delta = time - lasttime;
|
||||
if (delta < 0) {
|
||||
time = lasttime;
|
||||
delta = 0;
|
||||
}
|
||||
for (offset = 10; offset < delta; offset += 10) {
|
||||
if (lasttime + offset > maxtime)
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue