This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix long standing memory leak with pop and shift!
authorArtur Bergman <sky@nanisky.com>
Sat, 4 Jan 2003 01:27:55 +0000 (01:27 +0000)
committerArtur Bergman <sky@nanisky.com>
Sat, 4 Jan 2003 01:27:55 +0000 (01:27 +0000)
p4raw-id: //depot/perl@18421

ext/threads/shared/shared.xs

index 2a08fb0..c5a210f 100644 (file)
@@ -813,8 +813,9 @@ CODE:
        SHARED_CONTEXT;
        sv = av_pop((AV*)SHAREDSvPTR(shared));
        CALLER_CONTEXT;
        SHARED_CONTEXT;
        sv = av_pop((AV*)SHAREDSvPTR(shared));
        CALLER_CONTEXT;
-       ST(0) = Nullsv;
+       ST(0) = sv_newmortal();
        Perl_sharedsv_associate(aTHX_ &ST(0), sv, 0);
        Perl_sharedsv_associate(aTHX_ &ST(0), sv, 0);
+       SvREFCNT_dec(sv);
        LEAVE_LOCK;
        XSRETURN(1);
 
        LEAVE_LOCK;
        XSRETURN(1);
 
@@ -827,8 +828,9 @@ CODE:
        SHARED_CONTEXT;
        sv = av_shift((AV*)SHAREDSvPTR(shared));
        CALLER_CONTEXT;
        SHARED_CONTEXT;
        sv = av_shift((AV*)SHAREDSvPTR(shared));
        CALLER_CONTEXT;
-       ST(0) = Nullsv;
+       ST(0) = sv_newmortal();
        Perl_sharedsv_associate(aTHX_ &ST(0), sv, 0);
        Perl_sharedsv_associate(aTHX_ &ST(0), sv, 0);
+       SvREFCNT_dec(sv);
        LEAVE_LOCK;
        XSRETURN(1);
 
        LEAVE_LOCK;
        XSRETURN(1);