From 80c17cc134eaeddd0f4b244925b21b222a16828e Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Thu, 30 Nov 2023 10:34:36 +1100 Subject: [PATCH] add tests for #21661 --- t/re/pat.t | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/t/re/pat.t b/t/re/pat.t index ff61ed54c22c..6a6e40bded0d 100644 --- a/t/re/pat.t +++ b/t/re/pat.t @@ -28,7 +28,7 @@ skip_all_without_unicode_tables(); my $has_locales = locales_enabled('LC_CTYPE'); my $utf8_locale = find_utf8_ctype_locale(); -plan tests => 1265; # Update this when adding/deleting tests. +plan tests => 1267; # Update this when adding/deleting tests. run_tests() unless caller; @@ -2512,6 +2512,22 @@ SKIP: ok($str =~ s/$copy/PQR/, 'replaced $copy with PQR'); is($str, "PQR", 'final string should be PQR'); } + { + # github #21661 + fresh_perl_is(<<'PROG', <<'EXPECT', {}, "double-free on fatal warn with existing error"); +use warnings FATAL => qw(all); +/() {}/X; +PROG +Unknown regexp modifier "/X" at - line 2, at end of line +Unescaped left brace in regex is passed through in regex; marked by <-- HERE in m/() { <-- HERE }/ at - line 2. +Execution of - aborted due to compilation errors. +EXPECT + fresh_perl_is(<<'PROG', "", {}, "leak if __WARN__ handler dies"); +use warnings; +local $SIG{__WARN__} = sub { die; }; +eval "qr/()x{/;" for 1..10; +PROG + } } # End of sub run_tests 1;