[mod_dialplan_asterisk] Coverity CID 1214207 (Resource leak)

This commit is contained in:
Jakub Karolczyk 2023-04-06 11:27:19 +01:00
parent 73ea37c5ab
commit 99e26d3448
1 changed files with 8 additions and 0 deletions

View File

@ -142,6 +142,7 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt)
if (!caller_profile || zstr(caller_profile->destination_number)) { if (!caller_profile || zstr(caller_profile->destination_number)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Obtaining Profile!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Obtaining Profile!\n");
return NULL; return NULL;
} }
@ -150,6 +151,7 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt)
if (!switch_config_open_file(&cfg, cf)) { if (!switch_config_open_file(&cfg, cf)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf);
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return NULL; return NULL;
} }
@ -226,12 +228,14 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt)
} }
} else { } else {
if (pattern && strcasecmp(pattern, field_data)) { if (pattern && strcasecmp(pattern, field_data)) {
switch_safe_free(field_expanded);
continue; continue;
} }
} }
if (cid) { if (cid) {
if (strcasecmp(cid, caller_profile->caller_id_number)) { if (strcasecmp(cid, caller_profile->caller_id_number)) {
switch_safe_free(field_expanded);
continue; continue;
} }
} }
@ -266,15 +270,19 @@ SWITCH_STANDARD_DIALPLAN(asterisk_dialplan_hunt)
switch_perform_substitution(re, proceed, argument, field_data, substituted, sizeof(substituted), ovector); switch_perform_substitution(re, proceed, argument, field_data, substituted, sizeof(substituted), ovector);
argument = substituted; argument = substituted;
} }
switch_regex_safe_free(re); switch_regex_safe_free(re);
if (!extension) { if (!extension) {
if (zstr(field_data)) { if (zstr(field_data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "No extension!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "No extension!\n");
switch_safe_free(field_expanded);
break; break;
} }
if ((extension = switch_caller_extension_new(session, field_data, field_data)) == 0) { if ((extension = switch_caller_extension_new(session, field_data, field_data)) == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
switch_safe_free(field_expanded);
break; break;
} }
} }