From: Dave Mitchell Date: Tue, 3 Jan 2006 02:20:28 +0000 (+0000) Subject: ithreads: SVs that were only on the tmps stack leaked X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=34394ecd;p=p5sagit%2Fp5-mst-13.2.git ithreads: SVs that were only on the tmps stack leaked p4raw-id: //depot/perl@26591 --- diff --git a/sv.c b/sv.c index 9cc9c37..d32bd99 100644 --- a/sv.c +++ b/sv.c @@ -10767,6 +10767,20 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, else { init_stacks(); ENTER; /* perl_destruct() wants to LEAVE; */ + + /* although we're not duplicating the tmps stack, we should still + * add entries for any SVs on the tmps stack that got cloned by a + * non-refcount means (eg a temp in @_); otherwise they will be + * orphaned + */ + for (i = 0; i<= proto_perl->Ttmps_ix; i++) { + SV *nsv = (SV*)ptr_table_fetch(PL_ptr_table, + proto_perl->Ttmps_stack[i]); + if (nsv && !SvREFCNT(nsv)) { + EXTEND_MORTAL(1); + PL_tmps_stack[++PL_tmps_ix] = SvREFCNT_inc(nsv); + } + } } PL_start_env = proto_perl->Tstart_env; /* XXXXXX */