From d44d8510db26ff58f718d9bb23a5ca91b4fb4a3e Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Tue, 6 Feb 2007 18:37:01 +0000 Subject: [PATCH] some more protection against printing null. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4137 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/mod_sofia.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index eae5e77b06..ac094a658c 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -2048,7 +2048,9 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi } set_local_sdp(tech_pvt, NULL, 0, NULL, 0); activate_rtp(tech_pvt); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Ring SDP:\n%s\n", tech_pvt->local_sdp_str); + if (tech_pvt->local_sdp_str) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Ring SDP:\n%s\n", tech_pvt->local_sdp_str); + } nua_respond(tech_pvt->nh, SIP_183_SESSION_PROGRESS, @@ -2172,9 +2174,10 @@ static void logger(void *logarg, char const *fmt, va_list ap) } #endif } - - switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, (char*) "%s", data); - free(data); + if (data) { + switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, (char*) "%s", data); + free(data); + } } @@ -2630,7 +2633,7 @@ static void sip_i_message(int status, if ((ci = switch_loadable_module_get_chat_interface(proto))) { ci->chat_send(SOFIA_CHAT_PROTO, from_addr, to_addr, "", msg, full_from); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invaid Chat Interface [%s]!\n", proto); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invaid Chat Interface [%s]!\n", proto ? proto : "(none)"); } } @@ -3024,6 +3027,10 @@ static char *get_auth_data(char *dbname, char *nonce, char *npassword, size_t le switch_mutex_lock(mutex); } + if (!dbname) { + goto end; + } + if (!(db = switch_core_db_open_file(dbname))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", dbname); goto end;