From 67427b0396abd60ccd94edd52a2be3d1fe5d1f2e Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 9 May 2008 19:35:51 +0000 Subject: [PATCH] fix small issue git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8341 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/mod_sofia.h | 1 + src/mod/endpoints/mod_sofia/sofia.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 153c0fd1d2..45e9bc6ff6 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -101,6 +101,7 @@ struct sofia_private { sofia_gateway_t *gateway; char gateway_name[512]; int destroy_nh; + int destroy_me; }; #define set_param(ptr,val) if (ptr) {free(ptr) ; ptr = NULL;} if (val) {ptr = strdup(val);} diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index b43ade9a44..5a2d6430d1 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -350,6 +350,11 @@ void sofia_event_callback(nua_event_t event, break; } + if (sofia_private && sofia_private->destroy_me) { + free(sofia_private); + sofia_private = NULL; + } + if (gateway) { sofia_reg_release_gateway(gateway); } @@ -2108,14 +2113,14 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, if (tech_pvt->sofia_private) { sofia_private = tech_pvt->sofia_private; tech_pvt->sofia_private = NULL; - free(sofia_private); + sofia_private->destroy_me = 1; } tech_pvt->nh = NULL; } else if (sofia_private) { - free(sofia_private); + sofia_private->destroy_me = 1; } if (nh) {