From fa2f1b6eb06e65e6426cc3a488c6cb5c960e7d49 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 15 Sep 2012 20:47:53 -0700 Subject: [PATCH] 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 --- main.c | 3 +++ 1 file changed, 3 insertions(+) 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;