From 8c8657f9965ccebc481a741bd8d525f13ff5b8b0 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 29 Jul 2014 12:50:06 -0300 Subject: Don't cross link events between displayed_dive and current_dive The copy_dive assumed that the event being removed was from current_dive, wich was until a very recent past. now it can't assume that anymore, so instead of setting ev = assumed_dive->event->next, we do a ev = current_dive->event->next. Fixes #663 Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- dive.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'dive.c') diff --git a/dive.c b/dive.c index acab8ff52..139afe23e 100644 --- a/dive.c +++ b/dive.c @@ -70,8 +70,13 @@ void remove_event(struct event* event) while (ep && !same_event(*ep, event)) ep = &(*ep)->next; if (ep) { - *ep = event->next; - free(event); + /* we can't link directly with event->next + * because 'event' can be a copy from another + * dive (for instance the displayed_dive + * that we use on the interface to show things). */ + struct event *temp = (*ep)->next; + free(*ep); + *ep = temp; } } -- cgit v1.2.3-70-g09d2