From: Andrey Volk Date: Sat, 12 Jul 2025 19:10:09 +0000 (+0000) Subject: mod_translate X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e426c4a9578188a08c01739d9e6c26ebd8880d83;p=thirdparty%2Ffreeswitch.git mod_translate --- diff --git a/src/mod/applications/mod_translate/mod_translate.c b/src/mod/applications/mod_translate/mod_translate.c index 34b1ad54fc..cc31b1f8ea 100644 --- a/src/mod/applications/mod_translate/mod_translate.c +++ b/src/mod/applications/mod_translate/mod_translate.c @@ -117,7 +117,8 @@ static void translate_number(char *number, char *profile, char **translated, swi translate_rule_t *hi = NULL; translate_rule_t *rule = NULL; switch_regex_t *re = NULL; - int proceed = 0, ovector[30]; + switch_regex_match_t *match_data = NULL; + int proceed = 0; char *substituted = NULL, *subbed = NULL; uint32_t len = 0; @@ -136,17 +137,18 @@ static void translate_number(char *number, char *profile, char **translated, swi for (rule = hi; rule; rule = rule->next) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s =~ /%s/\n", number, rule->regex); - if ((proceed = switch_regex_perform(number, rule->regex, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) { + if ((proceed = switch_regex_perform(number, rule->regex, &re, &match_data))) { len = (uint32_t) (strlen(number) + strlen(rule->replace) + 10) * proceed; if (!(substituted = malloc(len))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); + switch_regex_match_safe_free(match_data); switch_regex_safe_free(re); goto end; } memset(substituted, 0, len); - switch_perform_substitution(re, proceed, rule->replace, number, substituted, len, ovector); + switch_perform_substitution(match_data, rule->replace, substituted, len); if ((switch_string_var_check_const(substituted) || switch_string_has_escaped_data(substituted))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "perform variable expansion\n"); @@ -169,6 +171,7 @@ static void translate_number(char *number, char *profile, char **translated, swi switch_safe_free(subbed); } + switch_regex_match_safe_free(match_data); switch_regex_safe_free(re); break; }