Skip to content

Commit e9ffbac

Browse files
committed
regcomp.c: Use utf8_to_uv_or_die over utf8n_to_uvchr
This will croak on malformed input. The previous behavior was to continue on using invalid data.
1 parent a3b43aa commit e9ffbac

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

regcomp.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6675,8 +6675,8 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
66756675
normal_default:
66766676
if (! UTF8_IS_INVARIANT(*p) && UTF) {
66776677
STRLEN numlen;
6678-
ender = utf8n_to_uvchr((U8*)p, RExC_end - p,
6679-
&numlen, UTF8_ALLOW_DEFAULT);
6678+
ender = utf8_to_uv_or_die((U8*) p, (U8*) RExC_end,
6679+
&numlen);
66806680
p += numlen;
66816681
}
66826682
else
@@ -9708,9 +9708,8 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
97089708
non_portable_endpoint = 0;
97099709
}
97109710
if (UTF && ! UTF8_IS_INVARIANT(* RExC_parse)) {
9711-
value = utf8n_to_uvchr((U8*)RExC_parse,
9712-
RExC_end - RExC_parse,
9713-
&numlen, UTF8_ALLOW_DEFAULT);
9711+
value = utf8_to_uv_or_die((U8*) RExC_parse, (U8*) RExC_end,
9712+
&numlen);
97149713
RExC_parse_inc_by(numlen);
97159714
}
97169715
else {
@@ -9772,9 +9771,8 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
97729771
}
97739772

97749773
if (UTF && ! UTF8_IS_INVARIANT(UCHARAT(RExC_parse))) {
9775-
value = utf8n_to_uvchr((U8*)RExC_parse,
9776-
RExC_end - RExC_parse,
9777-
&numlen, UTF8_ALLOW_DEFAULT);
9774+
value = utf8_to_uv_or_die((U8*) RExC_parse, (U8*) RExC_end,
9775+
&numlen);
97789776
RExC_parse_inc_by(numlen);
97799777
}
97809778
else {

0 commit comments

Comments
 (0)