summaryrefslogtreecommitdiff
path: root/ext/Opcode
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-10-22 11:06:35 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-10-22 16:09:59 -0700
commit03d9f026ae253e9e69212a3cf6f1944437e9f070 (patch)
tree3c21bc6f46fb6b331a571f5c095fea8660fb1213 /ext/Opcode
parentac73ea1ec401df889d312b067f78b618f7ffecc3 (diff)
downloadperl-03d9f026ae253e9e69212a3cf6f1944437e9f070.tar.gz
[perl #101486] Make PL_curstash refcounted
This stops PL_curstash from pointing to a freed-and-reused scalar in cases like ‘package Foo; BEGIN {*Foo:: = *Bar::}’. In such cases, another BEGIN block, or any subroutine definition, would cause a crash. Now it just happily proceeds. newATTRSUB and newXS have been modified not to call mro_method_changed_in in such cases, as it doesn’t make sense.
Diffstat (limited to 'ext/Opcode')
-rw-r--r--ext/Opcode/Opcode.pm2
-rw-r--r--ext/Opcode/Opcode.xs4
2 files changed, 3 insertions, 3 deletions
diff --git a/ext/Opcode/Opcode.pm b/ext/Opcode/Opcode.pm
index deec0bfedf..b9d9bbca47 100644
--- a/ext/Opcode/Opcode.pm
+++ b/ext/Opcode/Opcode.pm
@@ -6,7 +6,7 @@ use strict;
our($VERSION, @ISA, @EXPORT_OK);
-$VERSION = "1.20";
+$VERSION = "1.21";
use Carp;
use Exporter ();
diff --git a/ext/Opcode/Opcode.xs b/ext/Opcode/Opcode.xs
index 587c2994ee..4e6af8d6d5 100644
--- a/ext/Opcode/Opcode.xs
+++ b/ext/Opcode/Opcode.xs
@@ -294,8 +294,8 @@ PPCODE:
/* the assignment to global defstash changes our sense of 'main' */
PL_defstash = gv_stashsv(Package, GV_ADDWARN); /* should exist already */
- save_hptr(&PL_curstash);
- PL_curstash = PL_defstash;
+ SAVEGENERICSV(PL_curstash);
+ PL_curstash = (HV *)SvREFCNT_inc_simple(PL_defstash);
/* defstash must itself contain a main:: so we'll add that now */
/* take care with the ref counts (was cause of long standing bug) */