Skip to content

Commit

Permalink
Don't SEGV while warning about redefining the format STDOUT. Fixes RT…
Browse files Browse the repository at this point in the history
… #64562.
  • Loading branch information
nwc10 committed Apr 9, 2009
1 parent 5a8cf36 commit ee6d278
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
10 changes: 7 additions & 3 deletions op.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 18 additions & 1 deletion t/op/write.t
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ee6d278

Please sign in to comment.