diff --git a/src/include/switch_cpp.h b/src/include/switch_cpp.h index 8feb7c036b..167204b074 100644 --- a/src/include/switch_cpp.h +++ b/src/include/switch_cpp.h @@ -13,7 +13,7 @@ extern "C" { #define this_check_void() do { if (!this) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "object is not initalized\n");}} while(0) #define sanity_check(x) do { if (!(session && allocated)) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return x;}} while(0) #define sanity_check_noreturn do { if (!(session && allocated)) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return;}} while(0) -#define init_vars() do { allocated = 0; session = NULL; channel = NULL; uuid = NULL; tts_name = NULL; voice_name = NULL; xml_cdr_text = NULL; memset(&args, 0, sizeof(args)); ap = NULL; caller_profile.source = "mod_unknown"; caller_profile.dialplan = ""; caller_profile.context = ""; caller_profile.caller_id_name = ""; caller_profile.caller_id_number = ""; caller_profile.network_addr = ""; caller_profile.ani = ""; caller_profile.aniii = ""; caller_profile.rdnis = ""; caller_profile.username = ""; on_hangup = NULL; memset(&cb_state, 0, sizeof(cb_state)); hook_state = CS_NEW; } while(0) +#define init_vars() do { allocated = 0; session = NULL; channel = NULL; uuid = NULL; tts_name = NULL; voice_name = NULL; xml_cdr_text = NULL; memset(&caller_profile, 0, sizeof(caller_profile)); memset(&args, 0, sizeof(args)); ap = NULL; caller_profile.source = "mod_unknown"; caller_profile.dialplan = ""; caller_profile.context = ""; caller_profile.caller_id_name = ""; caller_profile.caller_id_number = ""; caller_profile.network_addr = ""; caller_profile.ani = ""; caller_profile.aniii = ""; caller_profile.rdnis = ""; caller_profile.username = ""; on_hangup = NULL; memset(&cb_state, 0, sizeof(cb_state)); hook_state = CS_NEW; } while(0) //// C++ Interface: switch_to_cpp_mempool//// Description: This class allows for overloading the new operator to allocate from a switch_memory_pool_t//// Author: Yossi Neiman , (C) 2007//// Copyright: See COPYING file that comes with this distribution// #if 0 #ifndef SWITCHTOMEMPOOL diff --git a/src/switch_cpp.cpp b/src/switch_cpp.cpp index c806bd0ccc..07cea5c2fc 100644 --- a/src/switch_cpp.cpp +++ b/src/switch_cpp.cpp @@ -402,7 +402,15 @@ SWITCH_DECLARE_CONSTRUCTOR CoreSession::~CoreSession() { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CoreSession::~CoreSession desctructor\n"); switch_channel_t *channel = NULL; - + + init_vars(); + this_check_void(); + + switch_safe_free(xml_cdr_text); + switch_safe_free(uuid); + switch_safe_free(tts_name); + switch_safe_free(voice_name); + if (session) { channel = switch_core_session_get_channel(session); if (switch_test_flag(this, S_HUP) && !switch_channel_test_flag(channel, CF_TRANSFER)) { @@ -411,10 +419,7 @@ SWITCH_DECLARE_CONSTRUCTOR CoreSession::~CoreSession() switch_core_session_rwunlock(session); } - switch_safe_free(xml_cdr_text); - switch_safe_free(uuid); - switch_safe_free(tts_name); - switch_safe_free(voice_name); + } SWITCH_DECLARE(char *) CoreSession::getXMLCDR() @@ -783,7 +788,6 @@ SWITCH_DECLARE(int) CoreSession::originate(CoreSession *a_leg_session, char *des switch_call_cause_t cause; this_check(0); - sanity_check(0); cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;