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