Просмотр исходного кода

cnxcc: more safety checks for call structure

Daniel-Constantin Mierla 9 лет назад
Родитель
Сommit
6985a2953b
1 измененных файлов с 12 добавлено и 8 удалено
  1. 12 8
      modules/cnxcc/cnxcc_mod.c

+ 12 - 8
modules/cnxcc/cnxcc_mod.c

@@ -889,14 +889,18 @@ void terminate_all_calls(credit_data_t *credit_data) {
 	credit_data->deallocating = 1;
 
 	clist_foreach_safe(credit_data->call_list, call, tmp, next) {
-		LM_DBG("Killing call with CID [%.*s]\n", call->sip_data.callid.len, call->sip_data.callid.s);
-
-		/*
-		 * Update number of calls forced to end
-		 */
-		_data.stats->dropped++;
-		terminate_call(call);
-		__free_call(call);
+		if(call->sip_data.callid.s!=NULL) {
+			LM_DBG("Killing call with CID [%.*s]\n", call->sip_data.callid.len, call->sip_data.callid.s);
+
+			/*
+			 * Update number of calls forced to end
+			 */
+			_data.stats->dropped++;
+			terminate_call(call);
+			__free_call(call);
+		} else {
+			LM_WARN("invalid call structure %p\n", call);
+		}
 	}
 }