APItest.xs: Fix mem leak in lexsub test
authorFather Chrysostomos <sprout@cpan.org>
Mon, 1 Oct 2012 06:31:40 +0000 (23:31 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 1 Oct 2012 07:04:10 +0000 (00:04 -0700)
Though this is harmless, since the test script is short-lived, it is
good to fix it in case this test is copied by module authors.

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;