Browse code

cnxcc: safety check for credit data search return value

Daniel-Constantin Mierla authored on 15/07/2017 07:01:38
Showing 1 changed files
... ...
@@ -914,14 +914,21 @@ void terminate_all_calls(credit_data_t *credit_data) {
914 914
             LM_ERR("BUG: Something went terribly wrong\n");
915 915
             return;
916 916
     }
917
-    
918
-	cd_entry = str_hash_get(hts->credit_data_by_client, credit_data->call_list->client_id.s, credit_data->call_list->client_id.len);
919 917
 
918
+	cd_entry = str_hash_get(hts->credit_data_by_client,
919
+			credit_data->call_list->client_id.s,
920
+			credit_data->call_list->client_id.len);
921
+
922
+	if(cd_entry==NULL) {
923
+		LM_WARN("credit data itme not found\n");
924
+		return;
925
+	}
920 926
 	credit_data->deallocating = 1;
921 927
 
922 928
 	clist_foreach_safe(credit_data->call_list, call, tmp, next) {
923 929
 		if(call->sip_data.callid.s!=NULL) {
924
-			LM_DBG("Killing call with CID [%.*s]\n", call->sip_data.callid.len, call->sip_data.callid.s);
930
+			LM_DBG("Killing call with CID [%.*s]\n", call->sip_data.callid.len,
931
+					call->sip_data.callid.s);
925 932
 
926 933
 			/*
927 934
 			 * Update number of calls forced to end
... ...
@@ -936,29 +943,29 @@ void terminate_all_calls(credit_data_t *credit_data) {
936 943
 
937 944
 	cnxcc_lock(hts->lock);
938 945
 
939
-	if (_data.redis) {                                                                                                                                                               
946
+	if (_data.redis) {
940 947
 		redis_clean_up_if_last(credit_data);
941 948
 		shm_free(credit_data->str_id);
942 949
 	}
943
-    
950
+
944 951
 	/*
945 952
      * Remove the credit_data_t from the hash table
946 953
 	 */
947 954
 	str_hash_del(cd_entry);
948
-    
955
+
949 956
 	cnxcc_unlock(hts->lock);
950
-    
957
+
951 958
 	/*
952 959
 	 * Free client_id in list's root
953 960
 	 */
954 961
 	shm_free(credit_data->call_list->client_id.s);
955 962
 	shm_free(credit_data->call_list);
956
-    
963
+
957 964
 	/*
958 965
 	 * Release the lock since we are going to free the entry down below
959 966
 	 */
960 967
 	cnxcc_unlock(credit_data->lock);
961
-    
968
+
962 969
 	/*
963 970
 	 * Free the whole entry
964 971
 	 */