Fix session segfault

This commit is contained in:
suvendhu 2023-03-24 18:49:03 +05:30
parent 790706f578
commit 8e8b5fa761
2 changed files with 14 additions and 9 deletions

View file

@ -301,13 +301,18 @@ void set_cwmp_session_status(int status, int retry_time)
void rpc_exit()
{
while (cwmp_main->session->head_rpc_acs.next != &(cwmp_main->session->head_rpc_acs)) {
struct rpc *rpc = list_entry(cwmp_main->session->head_rpc_acs.next, struct rpc, list);
if (!rpc)
break;
if (rpc_acs_methods[rpc->type].extra_clean != NULL)
rpc_acs_methods[rpc->type].extra_clean(rpc);
cwmp_session_rpc_destructor(rpc);
if (cwmp_main == NULL || cwmp_main->session == NULL)
return;
if (!list_empty(&(cwmp_main->session->head_rpc_acs))) {
while (cwmp_main->session->head_rpc_acs.next != &(cwmp_main->session->head_rpc_acs)) {
struct rpc *rpc = list_entry(cwmp_main->session->head_rpc_acs.next, struct rpc, list);
if (!rpc)
break;
if (rpc_acs_methods[rpc->type].extra_clean != NULL)
rpc_acs_methods[rpc->type].extra_clean(rpc);
cwmp_session_rpc_destructor(rpc);
}
}
FREE(cwmp_main->session->rpc_cpe);
}

View file

@ -39,7 +39,6 @@ static int dm_iface_unit_tests_init(void **state)
static int dm_iface_unit_tests_clean(void **state)
{
icwmp_free_list_services();
clean_cwmp_session_structure();
FREE(cwmp_main->deviceid.manufacturer);
FREE(cwmp_main->deviceid.serialnumber);
FREE(cwmp_main->deviceid.productclass);
@ -58,10 +57,11 @@ static int dm_iface_unit_tests_clean(void **state)
FREE(cwmp_main->conf.connection_request_path);
FREE(cwmp_main->conf.default_wan_iface);
FREE(cwmp_main->conf.custom_notify_json);
FREE(cwmp_main);
cwmp_free_all_list_param_fault(&faults_array);
cwmp_free_all_dm_parameter_list(&list_set_param_value);
cwmp_session_exit();
clean_cwmp_session_structure();
FREE(cwmp_main);
return 0;
}