Commit d4f07ad8a7 for perl
commit d4f07ad8a7624a78348ec8d03de9c6da9fd4b552
Author: Leon Timmermans <fawaka@gmail.com>
Date: Mon Oct 5 22:58:58 2026 +0200
Don't narrow offset on \K rollback
Unlike all other offsets in the regex engine this wasn't widened in
99a90e5. Because of that a rollback to a position > 2GiB would result
in narrowing of the offset value.
I also renamed the value while I was at it, to make it more obvious why
this should be an SSize_t.
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 7eb63289c9..3ab61fc894 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -505,6 +505,10 @@ incorrectly truncated.
=item *
+The offset of a \K is no longer narrowed on rollback at an offset >2GiB.
+
+=item *
+
In some cases warnings that occurred while using unpack on an invalid
UTF-8 marked string would result in an invalid free. [GH #24913]
diff --git a/regexec.c b/regexec.c
index 565ca2da0e..8478caa030 100644
--- a/regexec.c
+++ b/regexec.c
@@ -7009,7 +7009,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
case KEEPS: /* \K */
/* update the startpoint */
- st->u.keeper.val = RXp_OFFS_START(rex,0);
+ st->u.keeper.offset = RXp_OFFS_START(rex,0);
RXp_OFFSp(rex)[0].start = locinput - reginfo->strbeg;
PUSH_STATE_GOTO(KEEPS_next, next, locinput, loceol,
script_run_begin);
@@ -7017,7 +7017,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
case KEEPS_next_fail:
/* rollback the start point change */
- RXp_OFFSp(rex)[0].start = st->u.keeper.val;
+ RXp_OFFSp(rex)[0].start = st->u.keeper.offset;
sayNO_SILENT;
NOT_REACHED; /* NOTREACHED */
diff --git a/regexp.h b/regexp.h
index 10b9f99dac..e9aaac1c8e 100644
--- a/regexp.h
+++ b/regexp.h
@@ -1024,7 +1024,7 @@ typedef struct regmatch_state {
} mark;
struct {
- int val;
+ SSize_t offset;
} keeper;
/* quantifiers - these members are used for storing state for