summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-04-28 03:07:54 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-04-28 03:07:54 +0000
commit6a7129a1faa6d28064c474b8f21af7ca723db9bf (patch)
tree0bb8ae5d162e68947f45eb8a0eb73f4954a32813 /op.c
parentb4296952a9752bfe134e4d73b69fab194db0c00e (diff)
downloadperl-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.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/op.c b/op.c
index 7ca60aebb9..681efae814 100644
--- a/op.c
+++ b/op.c
@@ -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;
}