summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--op.c10
-rwxr-xr-xt/op/write.t19
2 files changed, 25 insertions, 4 deletions
diff --git a/op.c b/op.c
index 517f6483ed..89ed5227da 100644
--- a/op.c
+++ b/op.c
@@ -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