[mod_translate] Coverity CID 1301006 (Resource leak)

This commit is contained in:
Jakub Karolczyk 2023-04-13 14:54:50 +01:00
parent b1bf3b0574
commit 0b05623cef
1 changed files with 10 additions and 3 deletions

View File

@ -130,6 +130,7 @@ static void translate_number(char *number, char *profile, char **translated, swi
hi = switch_core_hash_find_rdlock(globals.translate_profiles, (const char *)profile, globals.profile_hash_rwlock);
if (!hi) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "can't find key for profile matching [%s]\n", profile);
return;
}
@ -142,6 +143,7 @@ static void translate_number(char *number, char *profile, char **translated, swi
switch_regex_safe_free(re);
goto end;
}
memset(substituted, 0, len);
switch_perform_substitution(re, proceed, rule->replace, number, substituted, len, ovector);
@ -153,16 +155,21 @@ static void translate_number(char *number, char *profile, char **translated, swi
} else if (event) {
subbed = switch_event_expand_headers(event, substituted);
}
if (subbed != substituted) {
switch_safe_free(substituted);
}
if (session) {
substituted = switch_core_session_strdup(session, subbed);
} else {
substituted = switch_core_strdup(pool, subbed);
}
if (subbed != substituted) {
switch_safe_free(subbed);
}
switch_safe_free(subbed);
}
switch_regex_safe_free(re);
break;
}
}