summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2013-01-07 15:14:13 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-07 15:44:23 -0800
commit7e1f0d243bc7e73e9c9f479f5993a6a61ecfd65a (patch)
tree57b34cf8f2f0237e02fb14f158dcd5621dbcc583 /profile.c
parentc2bc6633ec19255aa5c083662f361250a3657b79 (diff)
downloadsubsurface-7e1f0d243bc7e73e9c9f479f5993a6a61ecfd65a.tar.gz
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>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/profile.c b/profile.c
index f9cb78a17..c1603c377 100644
--- a/profile.c
+++ b/profile.c
@@ -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;