From: Tim Jenness Date: Thu, 11 Jul 2002 10:15:45 +0000 (-1000) Subject: finall fix core dump in XS::Typemap X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c72de6e4fcf1475a6744c18dcaf8c2e06e1665bf;p=p5sagit%2Fp5-mst-13.2.git finall fix core dump in XS::Typemap Message-ID: p4raw-id: //depot/perl@17492 --- diff --git a/ext/XS/Typemap/Typemap.t b/ext/XS/Typemap/Typemap.t index 0cf1ab3..1699c99 100644 --- a/ext/XS/Typemap/Typemap.t +++ b/ext/XS/Typemap/Typemap.t @@ -314,11 +314,7 @@ if (defined $fh) { ok(print $fh "$lines[1]"); # close it using XS - # This works fine but causes a segmentation fault during global - # destruction when the glob associated with this filehandle is - # tidied up. -# ok( T_STDIO_close( $fh ) ); - ok(close($fh)); # using perlio to close the glob works fine + ok( T_STDIO_close( $fh ) ); # open from perl, and check contents open($fh, "< $testfile"); diff --git a/ext/XS/Typemap/Typemap.xs b/ext/XS/Typemap/Typemap.xs index feed61b..853b4ab 100644 --- a/ext/XS/Typemap/Typemap.xs +++ b/ext/XS/Typemap/Typemap.xs @@ -795,10 +795,17 @@ T_STDIO_open( file ) RETVAL SysRet -T_STDIO_close( stream ) - FILE * stream +T_STDIO_close( f ) + PerlIO * f + PREINIT: + FILE * stream; CODE: + /* Get the FILE* */ + stream = PerlIO_findFILE( f ); RETVAL = xsfclose( stream ); + /* Release the FILE* from the PerlIO system so that we do + not close the file twice */ + PerlIO_releaseFILE(f,stream); OUTPUT: RETVAL