fb6d68
Ported to 5.16.1:
fb6d68
fb6d68
From 4505a31f43ca4e1a0e9203b389f6d4bebab9d899 Mon Sep 17 00:00:00 2001
fb6d68
From: Father Chrysostomos <sprout@cpan.org>
fb6d68
Date: Tue, 9 Oct 2012 20:47:18 -0700
fb6d68
Subject: [PATCH] =?UTF-8?q?[perl=20#115206]=20Don=E2=80=99t=20crash=20when=20?=
fb6d68
 =?UTF-8?q?vivifying=20$|?=
fb6d68
MIME-Version: 1.0
fb6d68
Content-Type: text/plain; charset=UTF-8
fb6d68
Content-Transfer-Encoding: 8bit
fb6d68
fb6d68
It was trying to read the currently-selected handle without checking
fb6d68
whether it was selected.  It is actually not necessary to initialise
fb6d68
the variable this way, as the next use of get-magic on it will clobber
fb6d68
the cached value.
fb6d68
fb6d68
This initialisation was originally added in commit d8ce0c9a45.  The
fb6d68
bug it was fixing was probably caused by missing FETCH calls that are
fb6d68
no longer missing.
fb6d68
---
fb6d68
 gv.c         |    5 +----
fb6d68
 t/op/magic.t |    5 ++++-
fb6d68
 2 files changed, 5 insertions(+), 5 deletions(-)
fb6d68
fb6d68
diff --git a/gv.c b/gv.c
fb6d68
index f352452..cf02ca4 100644
fb6d68
--- a/gv.c
fb6d68
+++ b/gv.c
fb6d68
@@ -1913,10 +1913,6 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
fb6d68
 		Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX),
fb6d68
 				 "$%c is no longer supported", *name);
fb6d68
 	    break;
fb6d68
-	case '|':		/* $| */
fb6d68
-	    sv_setiv(GvSVn(gv), (IV)(IoFLAGS(GvIOp(PL_defoutgv)) & IOf_FLUSH) != 0);
fb6d68
-	    goto magicalize;
fb6d68
-
fb6d68
 	case '\010':	/* $^H */
fb6d68
 	    {
fb6d68
 		HV *const hv = GvHVn(gv);
fb6d68
@@ -1957,6 +1953,7 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
fb6d68
 	case '>':		/* $> */
fb6d68
 	case '\\':		/* $\ */
fb6d68
 	case '/':		/* $/ */
fb6d68
+	case '|':		/* $| */
fb6d68
 	case '$':		/* $$ */
fb6d68
 	case '\001':	/* $^A */
fb6d68
 	case '\003':	/* $^C */
fb6d68
diff --git a/t/op/magic.t b/t/op/magic.t
fb6d68
index 3fb1ea1..1bcfbd9 100644
fb6d68
--- a/t/op/magic.t
fb6d68
+++ b/t/op/magic.t
fb6d68
@@ -5,7 +5,7 @@ BEGIN {
fb6d68
     chdir 't' if -d 't';
fb6d68
     @INC = '../lib';
fb6d68
     require './test.pl';
fb6d68
-    plan (tests => 156);
fb6d68
+    plan (tests => 157);
fb6d68
 }
fb6d68
 
fb6d68
 # Test that defined() returns true for magic variables created on the fly,
fb6d68
@@ -581,6 +581,11 @@ SKIP: {
fb6d68
     }
fb6d68
 }
fb6d68
 
fb6d68
+# $|
fb6d68
+fresh_perl_is
fb6d68
+ 'select f; undef *f; ${q/|/}; print STDOUT qq|ok\n|', "ok\n", {}, 
fb6d68
+ '[perl #115206] no crash when vivifying $| while *{+select}{IO} is undef';
fb6d68
+
fb6d68
 # ^^^^^^^^^ New tests go here ^^^^^^^^^
fb6d68
 
fb6d68
 SKIP: {
fb6d68
-- 
fb6d68
1.7.7.6
fb6d68