diff options
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; } |