ext/PerlIO/via/via.xs freeing the wrong thing
Bo Lindbergh [Fri, 5 Jan 2007 19:19:53 +0000 (20:19 +0100)]
Message-Id: <C7070BEE-BFB6-4FA2-A50B-BF20CDB3B61F@hagernas.com>

p4raw-id: //depot/perl@29701

ext/PerlIO/via/via.xs

index 733ffd6..36e739a 100644 (file)
@@ -137,10 +137,10 @@ PerlIOVia_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg,
            s->obj = SvREFCNT_inc(arg);
            s->stash = gv_stashpvn(pkg, pkglen, FALSE);
            if (!s->stash) {
+               SvREFCNT_dec(s->obj);
                s->obj =
                    newSVpvn(Perl_form(aTHX_ "PerlIO::via::%s", pkg),
                             pkglen + 13);
-               SvREFCNT_dec(arg);
                s->stash = gv_stashpvn(SvPVX_const(s->obj), pkglen + 13, FALSE);
            }
            if (s->stash) {
@@ -156,8 +156,8 @@ PerlIOVia_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg,
                                     modesv, Nullsv);
                if (result) {
                    if (sv_isobject(result)) {
+                       SvREFCNT_dec(s->obj);
                        s->obj = SvREFCNT_inc(result);
-                       SvREFCNT_dec(arg);
                    }
                    else if (SvIV(result) != 0)
                        return SvIV(result);