diff --git a/daemon/ice.c b/daemon/ice.c index 346a4602e..b6e7b9c7f 100644 --- a/daemon/ice.c +++ b/daemon/ice.c @@ -471,9 +471,18 @@ static void ice_candidate_pairs_free(GQueue *q) { /* call must be locked */ void ice_shutdown(struct ice_agent **agp) { - struct ice_agent *ag = *agp; - if (!ag) + struct ice_agent *ag; + + if (!agp) { + ilog(LOG_ERR, "ice agp is NULL"); + return ; + } + + ag = *agp; + if (!ag) { + ilog(LOG_ERR, "ice ag is NULL"); return; + } __agent_deschedule(ag); @@ -481,6 +490,11 @@ void ice_shutdown(struct ice_agent **agp) { obj_put(ag); } static void __ice_agent_free_components(struct ice_agent *ag) { + if (!ag) { + ilog(LOG_ERR, "ice ag is NULL"); + return; + } + g_queue_clear(&ag->triggered); g_hash_table_destroy(ag->candidate_hash); g_hash_table_destroy(ag->pair_hash); @@ -497,6 +511,11 @@ static void __ice_agent_free_components(struct ice_agent *ag) { static void __ice_agent_free(void *p) { struct ice_agent *ag = p; + if (!ag) { + ilog(LOG_ERR, "ice ag is NULL"); + return; + } + __DBG("freeing ice_agent"); __ice_agent_free_components(ag); @@ -517,6 +536,11 @@ static void __agent_schedule_abs(struct ice_agent *ag, const struct timeval *tv) struct timeval nxt; long long diff; + if (!ag) { + ilog(LOG_ERR, "ice ag is NULL"); + return; + } + nxt = *tv; mutex_lock(&ice_agents_timers_lock); @@ -538,6 +562,12 @@ nope: } static void __agent_deschedule(struct ice_agent *ag) { int ret; + + if (!ag) { + ilog(LOG_ERR, "ice ag is NULL"); + return; + } + mutex_lock(&ice_agents_timers_lock); if (!ag->next_check.tv_sec) goto nope; /* already descheduled */ @@ -698,6 +728,11 @@ static void __do_ice_checks(struct ice_agent *ag) { struct timeval next_run = {0,0}; int have_more = 0; + if (!ag) { + ilog(LOG_ERR, "ice ag is NULL"); + return; + } + if (!ag->pwd[0].s) return; @@ -1001,6 +1036,11 @@ static int __check_valid(struct ice_agent *ag) { struct ice_candidate_pair *pair; struct interface_address *ifa; + if (!ag) { + ilog(LOG_ERR, "ice ag is NULL"); + return 0; + } + __get_complete_valid_pairs(&all_compos, ag); if (!all_compos.length) {