a couple more file handle bugfixes
authorDaniel Frett <daniel.frett@ccci.org>
Mon, 28 Feb 2011 19:47:28 +0000 (14:47 -0500)
committerDaniel Frett <daniel.frett@ccci.org>
Mon, 28 Feb 2011 19:47:28 +0000 (14:47 -0500)
-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

diff --git a/Fuse.xs b/Fuse.xs
index 964a755..440d603 100755 (executable)
--- 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);
        }