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