From 1729078f56fb01811424c19df60489726bb33aca Mon Sep 17 00:00:00 2001
From: Anthony Minessale <anthm@freeswitch.org>
Date: Sat, 16 Jul 2011 11:30:36 -0500
Subject: [PATCH] FS-3386

---
 src/mod/endpoints/mod_sofia/mod_sofia.h  | 4 ++--
 src/mod/endpoints/mod_sofia/sofia.c      | 1 +
 src/mod/endpoints/mod_sofia/sofia_glue.c | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h
index ec60df275d..466597af1a 100644
--- a/src/mod/endpoints/mod_sofia/mod_sofia.h
+++ b/src/mod/endpoints/mod_sofia/mod_sofia.h
@@ -159,8 +159,8 @@ struct sofia_private {
 
 #define set_param(ptr,val) if (ptr) {free(ptr) ; ptr = NULL;} if (val) {ptr = strdup(val);}
 #define set_anchor(t,m) if (t->Anchor) {delete t->Anchor;} t->Anchor = new SipMessage(m);
-//#define sofia_private_free(_pvt) if (_pvt && ! _pvt->is_static) {free(_pvt); _pvt = NULL;}
-#define sofia_private_free(_pvt) _pvt = NULL
+#define sofia_private_free(_pvt) if (_pvt && ! _pvt->is_static) {free(_pvt);} _pvt = NULL;
+
 
 /* Local Structures */
 /*************************************************************************************************************************************************************/
diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c
index a97d3a0b47..d54aa7896a 100644
--- a/src/mod/endpoints/mod_sofia/sofia.c
+++ b/src/mod/endpoints/mod_sofia/sofia.c
@@ -1240,6 +1240,7 @@ void sofia_event_callback(nua_event_t event,
 
 		memset(sofia_private, 0, sizeof(*sofia_private));
 		sofia_private->is_call++;
+		sofia_private->is_static++;
 		sofia_private->de = de;
 		nua_handle_bind(nh, sofia_private);
 		return;
diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c
index 4da775d683..c697e3cfe6 100644
--- a/src/mod/endpoints/mod_sofia/sofia_glue.c
+++ b/src/mod/endpoints/mod_sofia/sofia_glue.c
@@ -2308,6 +2308,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
 
 		memset(sofia_private, 0, sizeof(*sofia_private));
 		sofia_private->is_call++;
+		sofia_private->is_static++;
 
 		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));