From 046184b54132b7d391a28011c08cf2aec459aaab Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 27 Apr 2016 15:25:14 +0200 Subject: [PATCH] event.c: fix crash with event beeing freed twice in case of error --- coreapi/event.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/coreapi/event.c b/coreapi/event.c index e8d2ac49a..414887154 100644 --- a/coreapi/event.c +++ b/coreapi/event.c @@ -332,7 +332,17 @@ const char* linphone_event_get_custom_header(LinphoneEvent* ev, const char* name void linphone_event_terminate(LinphoneEvent *lev){ + // if event was already terminated (including on error), we should not terminate it again + // otherwise it will be unreffed twice. + if (lev->publish_state == LinphonePublishError || lev->publish_state == LinphoneSubscriptionTerminated) { + return; + } + if (lev->subscription_state == LinphoneSubscriptionError || lev->subscription_state == LinphoneSubscriptionTerminated) { + return; + } + lev->terminating=TRUE; + if (lev->dir==LinphoneSubscriptionIncoming){ sal_notify_close(lev->op); }else if (lev->dir==LinphoneSubscriptionOutgoing){