summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regexec.c6
-rw-r--r--t/re/pat_advanced.t13
2 files changed, 16 insertions, 3 deletions
diff --git a/regexec.c b/regexec.c
index 11c408fb3d..17a0dc69a4 100644
--- a/regexec.c
+++ b/regexec.c
@@ -5948,8 +5948,10 @@ S_reginclass(pTHX_ const regexp *prog, register const regnode *n, register const
if (do_utf8 && !UTF8_IS_INVARIANT(c)) {
c = utf8n_to_uvchr(p, UTF8_MAXBYTES, &len,
- (UTF8_ALLOW_DEFAULT & UTF8_ALLOW_ANYUV) | UTF8_CHECK_ONLY);
- /* see [perl #37836] for UTF8_ALLOW_ANYUV */
+ (UTF8_ALLOW_DEFAULT & UTF8_ALLOW_ANYUV)
+ | UTF8_ALLOW_FFFF | UTF8_CHECK_ONLY);
+ /* see [perl #37836] for UTF8_ALLOW_ANYUV; [perl #38293] for
+ * UTF8_ALLOW_FFFF */
if (len == (STRLEN)-1)
Perl_croak(aTHX_ "Malformed UTF-8 character (fatal)");
}
diff --git a/t/re/pat_advanced.t b/t/re/pat_advanced.t
index a0eec5858a..3a66a0c6b9 100644
--- a/t/re/pat_advanced.t
+++ b/t/re/pat_advanced.t
@@ -21,7 +21,7 @@ BEGIN {
}
-plan tests => 1142; # Update this when adding/deleting tests.
+plan tests => 1143; # Update this when adding/deleting tests.
run_tests() unless caller;
@@ -1770,6 +1770,17 @@ sub run_tests {
iseq $_, "!Bang!1!Bang!2!Bang!3!Bang!";
}
+ {
+ # Earlier versions of Perl said this was fatal.
+ local $Message = "U+0FFFF shouldn't crash the regex engine";
+ no warnings 'utf8';
+ my $a = eval "chr(65535)";
+ use warnings;
+ my $warning_message;
+ local $SIG{__WARN__} = sub { $warning_message = $_[0] };
+ eval $a =~ /[a-z]/;
+ ok(1); # If it didn't crash, it worked.
+ }
} # End of sub run_tests
1;