From 9ee13b723e0ec150e03dae569c71f370b4491405 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Wed, 5 Jan 2011 09:54:27 -0500 Subject: [PATCH] don't seg in edge case error conditions --- src/mod/applications/mod_fifo/mod_fifo.c | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index e9d7cfb0e6..3a6ef81353 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -582,6 +582,8 @@ static int check_caller_outbound_call(const char *key) { int x = 0; + if (!key) return x; + switch_mutex_lock(globals.caller_orig_mutex); x = !!switch_core_hash_find(globals.caller_orig_hash, key); switch_mutex_unlock(globals.caller_orig_mutex); @@ -592,6 +594,8 @@ static int check_caller_outbound_call(const char *key) static void add_caller_outbound_call(const char *key, switch_call_cause_t *cancel_cause) { + if (!key) return; + switch_mutex_lock(globals.caller_orig_mutex); switch_core_hash_insert(globals.caller_orig_hash, key, cancel_cause); switch_mutex_unlock(globals.caller_orig_mutex); @@ -599,6 +603,8 @@ static void add_caller_outbound_call(const char *key, switch_call_cause_t *cance static void del_caller_outbound_call(const char *key) { + if (!key) return; + switch_mutex_lock(globals.caller_orig_mutex); switch_core_hash_delete(globals.caller_orig_hash, key); switch_mutex_unlock(globals.caller_orig_mutex); @@ -608,6 +614,8 @@ static void cancel_caller_outbound_call(const char *key, switch_call_cause_t cau { switch_call_cause_t *cancel_cause = NULL; + if (!key) return; + switch_mutex_lock(globals.caller_orig_mutex); if ((cancel_cause = (switch_call_cause_t *) switch_core_hash_find(globals.caller_orig_hash, key))) { *cancel_cause = cause; @@ -624,6 +632,8 @@ static int check_bridge_call(const char *key) { int x = 0; + if (!key) return x; + switch_mutex_lock(globals.bridge_mutex); x = !!switch_core_hash_find(globals.bridge_hash, key); switch_mutex_unlock(globals.bridge_mutex); @@ -634,6 +644,8 @@ static int check_bridge_call(const char *key) static void add_bridge_call(const char *key) { + if (!key) return; + switch_mutex_lock(globals.bridge_mutex); switch_core_hash_insert(globals.bridge_hash, key, (void *)&marker); switch_mutex_unlock(globals.bridge_mutex); @@ -651,6 +663,8 @@ static int check_consumer_outbound_call(const char *key) { int x = 0; + if (!key) return x; + switch_mutex_lock(globals.consumer_orig_mutex); x = !!switch_core_hash_find(globals.consumer_orig_hash, key); switch_mutex_unlock(globals.consumer_orig_mutex); @@ -660,6 +674,8 @@ static int check_consumer_outbound_call(const char *key) static void add_consumer_outbound_call(const char *key, switch_call_cause_t *cancel_cause) { + if (!key) return; + switch_mutex_lock(globals.consumer_orig_mutex); switch_core_hash_insert(globals.consumer_orig_hash, key, cancel_cause); switch_mutex_unlock(globals.consumer_orig_mutex); @@ -667,6 +683,8 @@ static void add_consumer_outbound_call(const char *key, switch_call_cause_t *can static void del_consumer_outbound_call(const char *key) { + if (!key) return; + switch_mutex_lock(globals.consumer_orig_mutex); switch_core_hash_delete(globals.consumer_orig_hash, key); switch_mutex_unlock(globals.consumer_orig_mutex); @@ -676,6 +694,8 @@ static void cancel_consumer_outbound_call(const char *key, switch_call_cause_t c { switch_call_cause_t *cancel_cause = NULL; + if (!key) return; + switch_mutex_lock(globals.consumer_orig_mutex); if ((cancel_cause = (switch_call_cause_t *) switch_core_hash_find(globals.consumer_orig_hash, key))) { *cancel_cause = cause; @@ -1949,6 +1969,8 @@ static uint32_t fifo_add_outbound(const char *node_name, const char *url, uint32 priority = MAX_PRI - 1; } + if (!node_name) return 0; + switch_mutex_lock(globals.mutex); if (!(node = switch_core_hash_find(globals.fifo_hash, node_name))) { @@ -4166,6 +4188,8 @@ static void fifo_member_add(char *fifo_name, char *originate_string, int simo_co char *sql, *name_dup, *p; fifo_node_t *node = NULL; + if (!fifo_name) return; + if (switch_stristr("fifo_outbound_uuid=", originate_string)) { extract_fifo_outbound_uuid(originate_string, digest, sizeof(digest)); } else { @@ -4213,6 +4237,9 @@ static void fifo_member_del(char *fifo_name, char *originate_string) callback_t cbt = { 0 }; fifo_node_t *node = NULL; + if (!fifo_name) return; + + if (switch_stristr("fifo_outbound_uuid=", originate_string)) { extract_fifo_outbound_uuid(originate_string, digest, sizeof(digest)); } else {