From ad663ca29fa15dbba1bd5cfeb81c22cb68f36c3a Mon Sep 17 00:00:00 2001 From: trevora Date: Fri, 15 Jul 2016 13:52:44 -0400 Subject: [PATCH] Channel reference counts the stack object Updates the channel to increment and decrement the reference count for the SIP stack object. This fixes a bug where the stack was being freed while outstanding channel objects were present. --- src/channel.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/channel.c b/src/channel.c index 5bf26a1..7567358 100644 --- a/src/channel.c +++ b/src/channel.c @@ -119,6 +119,7 @@ static void belle_sip_channel_destroy(belle_sip_channel_t *obj){ } channel_end_send_background_task(obj); channel_end_recv_background_task(obj); + belle_sip_object_unref(obj->stack); /*normally this should do nothing because it sould have been terminated already, however leaving a background task open is so dangerous that we have to be paranoid*/ belle_sip_message("Channel [%p] destroyed",obj); @@ -726,6 +727,7 @@ void belle_sip_channel_init(belle_sip_channel_t *obj, belle_sip_stack_t *stack,c obj->peer_name=belle_sip_strdup(peername); obj->peer_port=peer_port; obj->stack=stack; + belle_sip_object_ref(obj->stack); if (bindip){ if (strcmp(bindip,"::0")!=0 && strcmp(bindip,"0.0.0.0")!=0) obj->local_ip=belle_sip_strdup(bindip); -- 2.9.0