diff options
author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2022-09-06 17:16:07 +0200 |
---|---|---|
committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2022-09-12 13:55:39 +0200 |
commit | 1f88976610d5bcc15ad58c9345848d736d64fd55 (patch) | |
tree | 931e89b580d55f13ddaaa24b397025701d2115a2 /glib/gregex.c | |
parent | 1185a1304a88319b58359105f2c1038ae4d7edce (diff) | |
download | glib-1f88976610d5bcc15ad58c9345848d736d64fd55.tar.gz |
gregex: Do not try access the undefined match offsets if we have no match
In case we're getting NO-MATCH "errors", we were still recomputing the
match offsets and taking decisions based on that, that might lead to
undefined behavior.
Avoid this by just returning early a FALSE result (but with no error) in
case there's no result to proceed on.
Fixes: #2741
Diffstat (limited to 'glib/gregex.c')
-rw-r--r-- | glib/gregex.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/glib/gregex.c b/glib/gregex.c index 219d9cee3..f2a5b5fd1 100644 --- a/glib/gregex.c +++ b/glib/gregex.c @@ -1073,6 +1073,12 @@ g_match_info_next (GMatchInfo *match_info, match_info->regex->pattern, match_error (match_info->matches)); return FALSE; } + else if (match_info->matches == PCRE2_ERROR_NOMATCH) + { + /* We're done with this match info */ + match_info->pos = -1; + return FALSE; + } else if (!recalc_match_offsets (match_info, error)) return FALSE; |