Skip to content

Commit ca76e4e

Browse files
committed
PATCH: [perl #126141]: qr/]]]]][\\/ fails to raise error
This was due to the trailing \ trying to look at the next character without verifying that one actually existed.
1 parent 88474c0 commit ca76e4e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

regcomp.c

+5
Original file line numberDiff line numberDiff line change
@@ -15718,6 +15718,11 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
1571815718
}
1571915719
else if (value == '\\') {
1572015720
/* Is a backslash; get the code point of the char after it */
15721+
15722+
if (RExC_parse >= RExC_end) {
15723+
vFAIL("Unmatched [");
15724+
}
15725+
1572115726
if (UTF && ! UTF8_IS_INVARIANT(UCHARAT(RExC_parse))) {
1572215727
value = utf8n_to_uvchr((U8*)RExC_parse,
1572315728
RExC_end - RExC_parse,

t/lib/warnings/regcomp

+7
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,10 @@ qr/(?[[:digit: ])/
7373
EXPECT
7474
Assuming NOT a POSIX class since no blanks are allowed in one in regex; marked by <-- HERE in m/(?[[:digit: ] <-- HERE )/ at - line 2.
7575
syntax error in (?[...]) in regex m/(?[[:digit: ])/ at - line 2.
76+
########
77+
# NAME [perl #126141]
78+
# OPTION fatal
79+
eval {/$_/}, print "$_ ==> ", $@ || "OK!\n" for "]]]]]]]]][\\", "]]]]][\\"
80+
EXPECT
81+
]]]]]]]]][\ ==> Unmatched [ in regex; marked by <-- HERE in m/]]]]]]]]][\ <-- HERE / at - line 2.
82+
]]]]][\ ==> Unmatched [ in regex; marked by <-- HERE in m/]]]]][\ <-- HERE / at - line 2.

0 commit comments

Comments
 (0)