summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-09-15 20:47:53 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-09-17 21:03:30 -0400
commitfa2f1b6eb06e65e6426cc3a488c6cb5c960e7d49 (patch)
treea7ece3bb4989ae0d95fc35ce68dd94816c12a824 /main.c
parent421366d0fb52db317276ec404adb0c45cf398f29 (diff)
downloadsubsurface-fa2f1b6eb06e65e6426cc3a488c6cb5c960e7d49.tar.gz
Fix potential crash when importing dives
If the last of the preexisting dives gets merged with a new dive we end up dereferencing a freed pointer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'main.c')
-rw-r--r--main.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/main.c b/main.c
index d66972cdc..3d9b43b41 100644
--- a/main.c
+++ b/main.c
@@ -125,6 +125,9 @@ void report_dives(gboolean is_imported)
if (!merged)
continue;
+ /* careful - we might free the dive that last points to. Oops... */
+ if (last == prev || last == dive)
+ last = merged;
free(prev);
free(dive);
*pp = merged;