perl/SOURCES/perl-5.24.1-perl-131085-Crash-with-sub-in-stash.patch
2021-09-10 13:25:44 +00:00

62 lines
1.8 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From cba9aa759f7ce8a4a80e748eb451f679042cd74b Mon Sep 17 00:00:00 2001
From: Father Chrysostomos <sprout@cpan.org>
Date: Fri, 7 Apr 2017 14:08:02 -0700
Subject: [PATCH] Crash with sub-in-stash
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Ported to 5.24.1:
commit 790acddeaa0d2c73524596048b129561225cf100
Author: Father Chrysostomos <sprout@cpan.org>
Date: Fri Apr 7 14:08:02 2017 -0700
[perl #131085] Crash with sub-in-stash
$ perl -e '$::{"A"} = sub {}; \&{"A"}'
Segmentation fault (core dumped)
The code that vivifies a typeglob out of a code ref assumed that the
CV had a name hek, which is always the case when perl itself puts the
code ref there (via sub A{}), but is not necessarily the case if
someone is insinuating other stuff into the stash.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
gv.c | 2 +-
t/op/gv.t | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/gv.c b/gv.c
index 3fda9b9..6690b64 100644
--- a/gv.c
+++ b/gv.c
@@ -421,7 +421,7 @@ Perl_gv_init_pvn(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, U32 flag
/* Not actually a constant. Just a regular sub. */
CV * const cv = (CV *)has_constant;
GvCV_set(gv,cv);
- if (CvSTASH(cv) == stash && (
+ if (CvNAMED(cv) && CvSTASH(cv) == stash && (
CvNAME_HEK(cv) == GvNAME_HEK(gv)
|| ( HEK_LEN(CvNAME_HEK(cv)) == HEK_LEN(GvNAME_HEK(gv))
&& HEK_FLAGS(CvNAME_HEK(cv)) != HEK_FLAGS(GvNAME_HEK(gv))
diff --git a/t/op/gv.t b/t/op/gv.t
index 03ae46e..cdaaef5 100644
--- a/t/op/gv.t
+++ b/t/op/gv.t
@@ -1170,6 +1170,10 @@ SKIP: {
is ($? & 127, 0,"[perl #128597] No crash when gp_free calls ckWARN_d");
}
+# [perl #131085] This used to crash; no ok() necessary.
+$::{"A131085"} = sub {}; \&{"A131085"};
+
+
__END__
Perl
Rules
--
2.9.4