Browse code

Update mod_stats.c Random crash in CTL handler

We have found a random crash in the CTL module handler and we are using kamailio 5.4.7. Based on the core log analysis, we have identified that, due to some of the RPC events this crash happens.

This crash happen when "rpc_mod_is_printed_one" funtion recevies the parameter ( mem_counter *stats ) as NULL. To avoid the crash, we have added the below code.

if ( stats == NULL || current == NULL )
{
LM_ERR("rpc_mod_is_printed_one -> funtion parameter contains null value \n");
return 1;
}

bensly-shanmugam authored on 21/09/2022 06:53:13 • GitHub committed on 21/09/2022 06:53:13
Showing 1 changed files
... ...
@@ -82,6 +82,12 @@ static const char* rpc_mod_mem_statsx_doc[2] = {
82 82
 /* test if the current mod info was already printed */
83 83
 static int rpc_mod_is_printed_one(mem_counter *stats, mem_counter *current) {
84 84
 	mem_counter *iter = stats;
85
+	
86
+	if ( stats == NULL || current == NULL )
87
+	{
88
+		LM_ERR("rpc_mod_is_printed_one -> funtion parameter contains null value \n");
89
+		return 1;
90
+	}
85 91
 
86 92
 	while (iter && iter != current) {
87 93
 		if (strcmp(iter->mname, current->mname) == 0) {