diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-04-28 03:07:54 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-04-28 03:07:54 +0000 |
commit | 6a7129a1faa6d28064c474b8f21af7ca723db9bf (patch) | |
tree | 0bb8ae5d162e68947f45eb8a0eb73f4954a32813 /op.c | |
parent | b4296952a9752bfe134e4d73b69fab194db0c00e (diff) | |
download | perl-6a7129a1faa6d28064c474b8f21af7ca723db9bf.tar.gz |
under useithreads, constant pad entries could inadvertently be
shared across threads (from Eric Blood <eblood@xmission.com>);
added Eric's test case to testsuite
p4raw-id: //depot/perl@5979
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -6433,9 +6433,18 @@ Perl_peep(pTHX_ register OP *o) * for reference counts, sv_upgrade() etc. */ if (cSVOP->op_sv) { PADOFFSET ix = pad_alloc(OP_CONST, SVs_PADTMP); - SvREFCNT_dec(PL_curpad[ix]); - SvPADTMP_on(cSVOPo->op_sv); - PL_curpad[ix] = cSVOPo->op_sv; + if (SvPADTMP(cSVOPo->op_sv)) { + /* If op_sv is already a PADTMP then it is being used by + * another pad, so make a copy. */ + sv_setsv(PL_curpad[ix],cSVOPo->op_sv); + SvREADONLY_on(PL_curpad[ix]); + SvREFCNT_dec(cSVOPo->op_sv); + } + else { + SvREFCNT_dec(PL_curpad[ix]); + SvPADTMP_on(cSVOPo->op_sv); + PL_curpad[ix] = cSVOPo->op_sv; + } cSVOPo->op_sv = Nullsv; o->op_targ = ix; } |