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>
This commit is contained in:
Dirk Hohndel 2012-09-15 20:47:53 -07:00
parent 421366d0fb
commit fa2f1b6eb0

3
main.c
View file

@ -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;