This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
APItest.xs: Fix mem leak in lexsub test
[perl5.git] / ext / XS-APItest / APItest.xs
index 8c045bc..1d2f6f3 100644 (file)
@@ -3445,7 +3445,8 @@ lexical_import(SV *name, CV *cv)
        SAVESPTR(PL_comppad_name); PL_comppad_name = PadlistNAMES(pl);
        SAVESPTR(PL_comppad);      PL_comppad      = PadlistARRAY(pl)[1];
        SAVESPTR(PL_curpad);       PL_curpad       = PadARRAY(PL_comppad);
-       off = pad_add_name_sv(newSVpvf("&%"SVf,name), padadd_STATE, 0, 0);
+       off = pad_add_name_sv(sv_2mortal(newSVpvf("&%"SVf,name)),
+                             padadd_STATE, 0, 0);
        SvREFCNT_dec(PL_curpad[off]);
        PL_curpad[off] = SvREFCNT_inc(cv);
        LEAVE;