From b49f32aef53fe9dd4fa5a9bf345fe9973faf14e3 Mon Sep 17 00:00:00 2001 From: Akash Deshmukh <319426432+akashdeshmukh-git@users.noreply.github.com> Date: Sun, 25 Oct 2026 07:26:45 +0000 Subject: [PATCH] match_next: Assert the preconditions of pcre2_next_match --- src/pcre2_match_next.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/pcre2_match_next.c b/src/pcre2_match_next.c index ae5a12ab5..9feb82252 100644 --- a/src/pcre2_match_next.c +++ b/src/pcre2_match_next.c @@ -95,6 +95,12 @@ do_bumpalong(pcre2_match_data *match_data, PCRE2_SIZE offset) PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION pcre2_next_match(pcre2_match_data *match_data, PCRE2_SIZE *pstart_offset, uint32_t *poptions) { + /* Preconditions on argument values */ + + PCRE2_ASSERT(match_data != NULL); + PCRE2_ASSERT(pstart_offset != NULL); + PCRE2_ASSERT(poptions != NULL); + PCRE2_SIZE start_offset = match_data->start_offset; PCRE2_SIZE *ovector = match_data->ovector; @@ -105,6 +111,10 @@ pcre2_next_match(pcre2_match_data *match_data, PCRE2_SIZE *pstart_offset, uint32 if (match_data->rc < 0) return FALSE; + /* Preconditions on argument state */ + + PCRE2_ASSERT(match_data->code != NULL); + /* Match succeeded: get the start offset for the next match */ /* Although \K can affect the position of ovector[0], there are no ways to do