summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pp_sys.c6
-rw-r--r--t/op/write.t12
2 files changed, 12 insertions, 6 deletions
diff --git a/pp_sys.c b/pp_sys.c
index cccbff3cd1..85fa25174b 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1477,9 +1477,8 @@ PP(pp_leavewrite)
SP = newsp; /* ignore retval of formline */
LEAVE;
- fp = IoOFP(io);
- if (!fp) {
- if (IoIFP(io))
+ if (!io || !(fp = IoOFP(io))) {
+ if (io && IoIFP(io))
report_wrongway_fh(gv, '<');
else
report_evil_fh(gv);
@@ -1500,7 +1499,6 @@ PP(pp_leavewrite)
PUSHs(&PL_sv_yes);
}
}
- /* bad_ofp: */
PL_formtarget = PL_bodytarget;
PERL_UNUSED_VAR(gimme);
RETURNOP(retop);
diff --git a/t/op/write.t b/t/op/write.t
index 6c16191878..a648902fb5 100644
--- 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 = 8 + 3 * 3 * 5 * 2 * 3 + 2 + 66 + 4 + 2 + 3 + 96 + 1;
+my $bug_tests = 8 + 3 * 3 * 5 * 2 * 3 + 2 + 66 + 4 + 2 + 3 + 96 + 2;
# number of tests in section 4
my $hmb_tests = 35;
@@ -992,7 +992,15 @@ undef *UNDEFFORMAT
.
write UNDEF;
pass "active format cannot be freed";
-close UNDEF or die "Could not close: $!";
+
+select +(select(UNDEF), $~ = "UNDEFFORMAT2")[0];
+format UNDEFFORMAT2 =
+@
+close UNDEF or die "Could not close: $!"; undef *UNDEF
+.
+write UNDEF;
+pass "freeing current handle in format";
+undef $^A;
#############################