--- JSON-XS/XS.xs 2016/02/21 16:18:19 1.126 +++ JSON-XS/XS.xs 2016/10/07 05:18:48 1.128 @@ -320,7 +320,6 @@ return 1; else if (*pv == '0') return 0; - } return -1; @@ -335,11 +334,14 @@ scalar = SvRV (scalar); - if (SvSTASH (scalar) == bool_stash) - return 1; + if (SvTYPE (scalar) >= SVt_PVMG) + { + if (SvSTASH (scalar) == bool_stash) + return 1; - if (!SvOBJECT (scalar) && ref_bool_type (scalar) >= 0) - return 1; + if (!SvOBJECT (scalar) && ref_bool_type (scalar) >= 0) + return 1; + } return 0; } @@ -1698,9 +1700,12 @@ * makes perl ignore the magic in subsequent accesses. * also make a copy of non-PV values, to get them into a clean * state (SvPV should do that, but it's buggy, see below). + * + * SvIsCOW_shared_hash works around a bug in perl (possibly 5.16), + * as reported by Reini Urban. */ /*SvGETMAGIC (string);*/ - if (SvMAGICAL (string) || !SvPOK (string)) + if (SvMAGICAL (string) || !SvPOK (string) || SvIsCOW_shared_hash (string)) string = sv_2mortal (newSVsv (string)); SvUPGRADE (string, SVt_PV);