From 284969589343310edf3dc45ca7119c8d4ffdd267 Mon Sep 17 00:00:00 2001 From: Daniel Frett Date: Mon, 28 Feb 2011 14:47:28 -0500 Subject: [PATCH] a couple more file handle bugfixes -only run mg_find for SV's of type SVt_PVMG per "if the SV is not of type SVt_PVMG, Perl may core dump." under Finding Magic in perlguts -hv_store_ent returns NULL when storing an SV to an HV with tie magic, such as when the HV is utilizing threads::shared --- Fuse.xs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Fuse.xs b/Fuse.xs index 964a755..440d603 100755 --- a/Fuse.xs +++ b/Fuse.xs @@ -97,11 +97,10 @@ void S_fh_store_handle(pTHX_ pMY_CXT_ struct fuse_file_info *fi, SV *sv) { SvSHARE(sv); } #endif - MAGIC *mg = mg_find(sv, PERL_MAGIC_shared_scalar); + MAGIC *mg = (SvTYPE(sv) == SVt_PVMG) ? mg_find(sv, PERL_MAGIC_shared_scalar) : NULL; fi->fh = mg ? PTR2IV(mg->mg_ptr) : PTR2IV(sv); if(hv_store_ent(MY_CXT.handles, FH_KEY(fi), SvREFCNT_inc(sv), 0) == NULL) { SvREFCNT_dec(sv); - return; } SvSETMAGIC(sv); } -- 2.20.1