summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gv.c5
-rw-r--r--t/op/gv.t12
2 files changed, 15 insertions, 2 deletions
diff --git a/gv.c b/gv.c
index 116d391148..720ba6b98c 100644
--- a/gv.c
+++ b/gv.c
@@ -1255,7 +1255,10 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
if (addmg) gv = (GV *)newSV(0);
else return NULL;
}
- else gv = *gvp;
+ else gv = *gvp, addmg = 0;
+ /* From this point on, addmg means gv has not been inserted in the
+ symtab yet. */
+
if (SvTYPE(gv) == SVt_PVGV) {
if (add) {
GvMULTI_on(gv);
diff --git a/t/op/gv.t b/t/op/gv.t
index d19132313f..8c0e31106c 100644
--- a/t/op/gv.t
+++ b/t/op/gv.t
@@ -12,7 +12,7 @@ BEGIN {
use warnings;
-plan( tests => 236 );
+plan( tests => 238 );
# type coercion on assignment
$foo = 'foo';
@@ -906,6 +906,16 @@ eval { *{;undef} = 3 };
like $@, qr/^Can't use an undefined value as a symbol reference at /,
'*{ ;undef } assignment';
+# [perl #99142] defined &{"foo"} when there is a constant stub
+# If I break your module, you get to have it mentioned in Perl's tests. :-)
+package HTTP::MobileAttribute::Plugin::Locator {
+ use constant LOCATOR_GPS => 1;
+ ::ok defined &{__PACKAGE__."::LOCATOR_GPS"},
+ 'defined &{"name of constant"}';
+ ::ok Internals::SvREFCNT(${__PACKAGE__."::"}{LOCATOR_GPS}),
+ "stash elem for slot is not freed prematurely";
+}
+
__END__
Perl
Rules