diff options
-rw-r--r-- | op.c | 10 | ||||
-rwxr-xr-x | t/op/write.t | 19 |
2 files changed, 25 insertions, 4 deletions
@@ -6166,9 +6166,13 @@ Perl_newFORM(pTHX_ I32 floor, OP *o, OP *block) const line_t oldline = CopLINE(PL_curcop); if (PL_parser && PL_parser->copline != NOLINE) CopLINE_set(PL_curcop, PL_parser->copline); - Perl_warner(aTHX_ packWARN(WARN_REDEFINE), - o ? "Format %"SVf" redefined" - : "Format STDOUT redefined", SVfARG(cSVOPo->op_sv)); + if (o) { + Perl_warner(aTHX_ packWARN(WARN_REDEFINE), + "Format %"SVf" redefined", SVfARG(cSVOPo->op_sv)); + } else { + Perl_warner(aTHX_ packWARN(WARN_REDEFINE), + "Format STDOUT redefined"); + } CopLINE_set(PL_curcop, oldline); } SvREFCNT_dec(cv); diff --git a/t/op/write.t b/t/op/write.t index 429936c97b..07b5f73710 100755 --- a/t/op/write.t +++ b/t/op/write.t @@ -61,7 +61,7 @@ for my $tref ( @NumTests ){ my $bas_tests = 20; # number of tests in section 3 -my $bug_tests = 4 + 3 * 3 * 5 * 2 * 3 + 2; +my $bug_tests = 4 + 3 * 3 * 5 * 2 * 3 + 2 + 1; # number of tests in section 4 my $hmb_tests = 35; @@ -607,6 +607,23 @@ $= = 10; select $oldfh; close STDOUT_DUP; +fresh_perl_like(<<'EOP', qr/^Format STDOUT redefined at/, {stderr => 1}, '#64562 - Segmentation fault with redefined formats and warnings'); +#!./perl + +use strict; +use warnings; # crashes! + +format = +. + +write; + +format = +. + +write; +EOP + ############################# ## Section 4 ## Add new tests *above* here |