summaryrefslogtreecommitdiff
path: root/cop.h
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-08-05 12:15:18 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-08-05 16:02:16 -0700
commitee23553f1b79f6259f9464480592b43a0c56e745 (patch)
treec7605a6a6b346c9930ec2c9f8963d693dd72aa39 /cop.h
parentd3810ef8d372a8c7b72ce050c1baa05f368045e6 (diff)
downloadperl-ee23553f1b79f6259f9464480592b43a0c56e745.tar.gz
Don’t let active formats be freed
This crashes: format FOO = @< undef *FOO . $~ = FOO; write The context stack needs to hold a reference count for formats, just as it does for subs.
Diffstat (limited to 'cop.h')
-rw-r--r--cop.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/cop.h b/cop.h
index 4cf9fe4027..ed55483a94 100644
--- a/cop.h
+++ b/cop.h
@@ -627,6 +627,7 @@ struct block_format {
cx->blk_format.gv = gv; \
cx->blk_format.retop = (retop); \
cx->blk_format.dfoutgv = PL_defoutgv; \
+ if (!CvDEPTH(cv)) SvREFCNT_inc_simple_void_NN(cv); \
CvDEPTH(cv)++; \
SvREFCNT_inc_void(cx->blk_format.dfoutgv)
@@ -681,6 +682,7 @@ struct block_format {
#define POPFORMAT(cx) \
setdefout(cx->blk_format.dfoutgv); \
CvDEPTH(cx->blk_format.cv)--; \
+ if (!CvDEPTH(cx->blk_format.cv)) SvREFCNT_dec(cx->blk_format.cv); \
SvREFCNT_dec(cx->blk_format.dfoutgv);
/* eval context */