diff --git a/lib/search/regex.c b/lib/search/regex.c index 863fb5767..0f2b7b6f7 100644 --- a/lib/search/regex.c +++ b/lib/search/regex.c @@ -277,6 +277,9 @@ mc_search__g_regex_match_full_safe (const GRegex * regex, char *string_safe, *p, *end; gboolean ret; + if (string_len < 0) + string_len = strlen (string); + if ((g_regex_get_compile_flags (regex) & G_REGEX_RAW) || g_utf8_validate (string, string_len, NULL)) { @@ -284,11 +287,6 @@ mc_search__g_regex_match_full_safe (const GRegex * regex, match_info, error); } - if (string_len < 0) - { - string_len = strlen (string); - } - /* Correctly handle embedded NULs while copying */ p = string_safe = g_malloc (string_len); memcpy (string_safe, string, string_len);