From e44ad9588cf56cf3192daea6ce7fe2feea3d8ebc Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 3 Oct 2007 23:42:40 +0000 Subject: [PATCH] be extra careful git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5789 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/sofia.c | 11 ++++++----- src/mod/endpoints/mod_sofia/sofia_glue.c | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 2d19f1069c..c0e9b3b8b2 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1360,8 +1360,9 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, } if (tech_pvt->sofia_private) { - free(tech_pvt->sofia_private); + sofia_private = tech_pvt->sofia_private; tech_pvt->sofia_private = NULL; + free(sofia_private); } tech_pvt->nh = NULL; @@ -1998,7 +1999,6 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ NULL, NULL, NULL, MODNAME, context, destination_number); if (tech_pvt->caller_profile) { - /* Loop thru unknown Headers Here so we can do something with them */ for (un = sip->sip_unknown; un; un = un->un_next) { if (!strncasecmp(un->un_name, "Alert-Info", 10)) { @@ -2031,11 +2031,12 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); } - if (!(tech_pvt->sofia_private = malloc(sizeof(*tech_pvt->sofia_private)))) { + if (!(sofia_private = malloc(sizeof(*sofia_private)))) { abort(); } - memset(tech_pvt->sofia_private, 0, sizeof(*tech_pvt->sofia_private)); - + memset(sofia_private, 0, sizeof(*sofia_private)); + tech_pvt->sofia_private = sofia_private; + if ((profile->pflags & PFLAG_PRESENCE)) { sofia_presence_set_chat_hash(tech_pvt, sip); } diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index be0cc68f2f..0370c131fe 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -511,7 +511,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) if (!tech_pvt->nh) { char *d_url = NULL, *url = NULL; - + sofia_private_t *sofia_private; if (switch_strlen_zero(tech_pvt->dest)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "URL Error! [%s]\n", tech_pvt->dest); return SWITCH_STATUS_FALSE; @@ -534,11 +534,11 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) switch_safe_free(d_url); - if (!(tech_pvt->sofia_private = malloc(sizeof(*tech_pvt->sofia_private)))) { + if (!(sofia_private = malloc(sizeof(*sofia_private)))) { abort(); } - memset(tech_pvt->sofia_private, 0, sizeof(*tech_pvt->sofia_private)); - + memset(sofia_private, 0, sizeof(*sofia_private)); + tech_pvt->sofia_private = sofia_private; switch_copy_string(tech_pvt->sofia_private->uuid, switch_core_session_get_uuid(session), sizeof(tech_pvt->sofia_private->uuid)); nua_handle_bind(tech_pvt->nh, tech_pvt->sofia_private);