diff options
author | David Mitchell <davem@iabyn.com> | 2014-12-12 19:52:22 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2014-12-12 19:52:22 +0000 |
commit | 50e5165b9638b94be310f15477b42935c79e82d5 (patch) | |
tree | 9f1a316cae3f3d1a5c00941b56fc34a052d584da /lib/ExtUtils | |
parent | 35ffb081a8fa691dd8ceff9c56d5d00b3ef81b96 (diff) | |
download | perl-50e5165b9638b94be310f15477b42935c79e82d5.tar.gz |
stop T_IN/OUT/INOUT/STDIO typemaps leaking
These typemaps (which are ancient; mostly going back to 1994 or so)
each leaked a GV and an RV.
Diffstat (limited to 'lib/ExtUtils')
-rw-r--r-- | lib/ExtUtils/typemap | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/lib/ExtUtils/typemap b/lib/ExtUtils/typemap index 0b09641f8d..831baad26c 100644 --- a/lib/ExtUtils/typemap +++ b/lib/ExtUtils/typemap @@ -388,32 +388,48 @@ T_STDIO { GV *gv = newGVgen("$Package"); PerlIO *fp = PerlIO_importFILE($var,0); - if ( fp && do_open(gv, "+<&", 3, FALSE, 0, 0, fp) ) - sv_setsv($arg, sv_bless(newRV((SV*)gv), gv_stashpv("$Package",1))); + if ( fp && do_open(gv, "+<&", 3, FALSE, 0, 0, fp) ) { + SV *rv = newRV_noinc((SV*)gv); + rv = sv_bless(rv, gv_stashpv("$Package",1)); + sv_setsv($arg, rv); + SvREFCNT_dec_NN(rv); + } else $arg = &PL_sv_undef; } T_IN { GV *gv = newGVgen("$Package"); - if ( do_open(gv, "<&", 2, FALSE, 0, 0, $var) ) - sv_setsv($arg, sv_bless(newRV((SV*)gv), gv_stashpv("$Package",1))); + if ( do_open(gv, "<&", 2, FALSE, 0, 0, $var) ) { + SV *rv = newRV_noinc((SV*)gv); + rv = sv_bless(rv, gv_stashpv("$Package",1)); + sv_setsv($arg, rv); + SvREFCNT_dec_NN(rv); + } else $arg = &PL_sv_undef; } T_INOUT { GV *gv = newGVgen("$Package"); - if ( do_open(gv, "+<&", 3, FALSE, 0, 0, $var) ) - sv_setsv($arg, sv_bless(newRV((SV*)gv), gv_stashpv("$Package",1))); + if ( do_open(gv, "+<&", 3, FALSE, 0, 0, $var) ) { + SV *rv = newRV_noinc((SV*)gv); + rv = sv_bless(rv, gv_stashpv("$Package",1)); + sv_setsv($arg, rv); + SvREFCNT_dec_NN(rv); + } else $arg = &PL_sv_undef; } T_OUT { GV *gv = newGVgen("$Package"); - if ( do_open(gv, "+>&", 3, FALSE, 0, 0, $var) ) - sv_setsv($arg, sv_bless(newRV((SV*)gv), gv_stashpv("$Package",1))); + if ( do_open(gv, "+>&", 3, FALSE, 0, 0, $var) ) { + SV *rv = newRV_noinc((SV*)gv); + rv = sv_bless(rv, gv_stashpv("$Package",1)); + sv_setsv($arg, rv); + SvREFCNT_dec_NN(rv); + } else $arg = &PL_sv_undef; } |