From 37de8e6253ed3e2b306b0cee633259c09dd0635c Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Tue, 6 Dec 2016 15:07:15 +0300 Subject: [PATCH] (mc_search__g_regex_match_full_safe): don't use negative string length. Signed-off-by: Andrew Borodin --- lib/search/regex.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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);