683572
From 85d4e0a35b2d44cf06a9343d23a2f84b8ebb9024 Mon Sep 17 00:00:00 2001
683572
From: Tony Cook <tony@develop-help.com>
683572
Date: Wed, 17 Jul 2019 11:32:50 +1000
683572
Subject: [PATCH] (perl #134291) propagate non-PVs in $@ in bare die()
683572
MIME-Version: 1.0
683572
Content-Type: text/plain; charset=UTF-8
683572
Content-Transfer-Encoding: 8bit
683572
683572
Signed-off-by: Petr Písař <ppisar@redhat.com>
683572
---
683572
 pp_sys.c   | 2 +-
683572
 t/op/die.t | 6 +++++-
683572
 2 files changed, 6 insertions(+), 2 deletions(-)
683572
683572
diff --git a/pp_sys.c b/pp_sys.c
683572
index 0214367ea6..251527785e 100644
683572
--- a/pp_sys.c
683572
+++ b/pp_sys.c
683572
@@ -498,7 +498,7 @@ PP(pp_die)
683572
 		}
683572
 	    }
683572
 	}
683572
-	else if (SvPOK(errsv) && SvCUR(errsv)) {
683572
+	else if (SvOK(errsv) && (SvPV_nomg(errsv,len), len)) {
683572
 	    exsv = sv_mortalcopy(errsv);
683572
 	    sv_catpvs(exsv, "\t...propagated");
683572
 	}
683572
diff --git a/t/op/die.t b/t/op/die.t
683572
index ef2b85f8f5..d6d7daffa5 100644
683572
--- a/t/op/die.t
683572
+++ b/t/op/die.t
683572
@@ -6,7 +6,7 @@ BEGIN {
683572
     set_up_inc('../lib');
683572
 }
683572
 
683572
-plan tests => 20;
683572
+plan tests => 21;
683572
 
683572
 eval {
683572
     eval {
683572
@@ -94,6 +94,10 @@ like($@, qr/\.{3}propagated at/, '... and appends a phrase');
683572
     local $SIG{__WARN__} = sub { $ok = 0 };
683572
     eval { undef $@; die };
683572
     is( $ok, 1, 'no warnings if $@ is undef' );
683572
+
683572
+    eval { $@ = 100; die };
683572
+    like($@."", qr/100\t\.{3}propagated at/,
683572
+         'check non-PVs in $@ are propagated');
683572
 }
683572
 
683572
 TODO: {
683572
-- 
683572
2.20.1
683572