From 7e1f0d243bc7e73e9c9f479f5993a6a61ecfd65a Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 7 Jan 2013 15:14:13 -0800 Subject: 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 Signed-off-by: Linus Torvalds Signed-off-by: Dirk Hohndel --- profile.c | 4 ++++ 1 file changed, 4 insertions(+) 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; -- cgit v1.2.3-70-g09d2