[sr-dev] git:master:5a577ab3: cnxcc: safety check for credit data search return value

Daniel-Constantin Mierla miconda at gmail.com
Sat Jul 15 09:33:34 CEST 2017


Module: kamailio
Branch: master
Commit: 5a577ab37719d48fb9a6bc1b200c8892d95ccbdc
URL: https://github.com/kamailio/kamailio/commit/5a577ab37719d48fb9a6bc1b200c8892d95ccbdc

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-07-15T09:01:38+02:00

cnxcc: safety check for credit data search return value

---

Modified: src/modules/cnxcc/cnxcc_mod.c

---

Diff:  https://github.com/kamailio/kamailio/commit/5a577ab37719d48fb9a6bc1b200c8892d95ccbdc.diff
Patch: https://github.com/kamailio/kamailio/commit/5a577ab37719d48fb9a6bc1b200c8892d95ccbdc.patch

---

diff --git a/src/modules/cnxcc/cnxcc_mod.c b/src/modules/cnxcc/cnxcc_mod.c
index ef897460e3..91a914f8d1 100644
--- a/src/modules/cnxcc/cnxcc_mod.c
+++ b/src/modules/cnxcc/cnxcc_mod.c
@@ -914,14 +914,21 @@ void terminate_all_calls(credit_data_t *credit_data) {
             LM_ERR("BUG: Something went terribly wrong\n");
             return;
     }
-    
-	cd_entry = str_hash_get(hts->credit_data_by_client, credit_data->call_list->client_id.s, credit_data->call_list->client_id.len);
 
+	cd_entry = str_hash_get(hts->credit_data_by_client,
+			credit_data->call_list->client_id.s,
+			credit_data->call_list->client_id.len);
+
+	if(cd_entry==NULL) {
+		LM_WARN("credit data itme not found\n");
+		return;
+	}
 	credit_data->deallocating = 1;
 
 	clist_foreach_safe(credit_data->call_list, call, tmp, next) {
 		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);
+			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
@@ -936,29 +943,29 @@ void terminate_all_calls(credit_data_t *credit_data) {
 
 	cnxcc_lock(hts->lock);
 
-	if (_data.redis) {                                                                                                                                                               
+	if (_data.redis) {
 		redis_clean_up_if_last(credit_data);
 		shm_free(credit_data->str_id);
 	}
-    
+
 	/*
      * Remove the credit_data_t from the hash table
 	 */
 	str_hash_del(cd_entry);
-    
+
 	cnxcc_unlock(hts->lock);
-    
+
 	/*
 	 * Free client_id in list's root
 	 */
 	shm_free(credit_data->call_list->client_id.s);
 	shm_free(credit_data->call_list);
-    
+
 	/*
 	 * Release the lock since we are going to free the entry down below
 	 */
 	cnxcc_unlock(credit_data->lock);
-    
+
 	/*
 	 * Free the whole entry
 	 */




More information about the sr-dev mailing list