From c2216b2616b124c58902b584fcf458ffbc4e2e06 Mon Sep 17 00:00:00 2001 From: Ervin Hegedus Date: Sat, 10 May 2025 13:34:56 +0200 Subject: [PATCH] fix: set 'rc' value for fill ovector correctly --- standalone/regex.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/standalone/regex.c b/standalone/regex.c index b70c031d..3a68a094 100644 --- a/standalone/regex.c +++ b/standalone/regex.c @@ -171,6 +171,11 @@ if (nmatch > 0) pcre2_match_data_free(match_data); pcre2_match_context_free(match_context); } + /* + pcre2_match() returns one more than the highest numbered capturing pair + that has been set (for example, 1 if there are no captures) - see pcre2_match's manual + */ + rc = pcre2_ret - 1; } #else rc = pcre_exec((const pcre *)preg->re_pcre, NULL, string, (int)strlen(string),