summaryrefslogtreecommitdiff
path: root/win32
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 /win32
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 'win32')
-rw-r--r--win32/perlhost.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/win32/perlhost.h b/win32/perlhost.h
index 02ecf109a1..e8f5fb4928 100644
--- a/win32/perlhost.h
+++ b/win32/perlhost.h
@@ -1757,6 +1757,10 @@ restart:
LEAVE;
FREETMPS;
PL_curstash = PL_defstash;
+ if (PL_curstash != PL_defstash) {
+ SvREFCNT_dec(PL_curstash);
+ PL_curstash = (HV *)SvREFCNT_inc(PL_defstash);
+ }
if (PL_endav && !PL_minus_c)
call_list(oldscope, PL_endav);
status = STATUS_EXIT;