X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=autovivification.xs;h=a8367a0a961e07b2f0b8665f4dec351e0c92e12d;hb=42b19c6def78e5230f6a618f54f113daee6349c5;hp=cb81c0f95bfe27cc60ac3e5a0e85bb4ca2b21317;hpb=69e618ff184122b6f498b61c5e8d0b607756c4a2;p=perl%2Fmodules%2Fautovivification.git diff --git a/autovivification.xs b/autovivification.xs index cb81c0f..a8367a0 100644 --- a/autovivification.xs +++ b/autovivification.xs @@ -94,7 +94,18 @@ STATIC UV a_detag(pTHX_ const SV *hint) { #else /* A_WORKAROUND_REQUIRE_PROPAGATION */ #define a_tag(B) newSVuv(B) -#define a_detag(H) (((H) && SvOK(H)) ? SvUVX(H) : 0) +/* PVs fetched from the hints chain have their SvLEN set to zero, so get the UV + * from a copy. */ +#define a_detag(H) \ + ((H) \ + ? (SvIOK(H) \ + ? SvUVX(H) \ + : (SvPOK(H) \ + ? sv_2uv(SvLEN(H) ? (H) : sv_mortalcopy(H)) \ + : 0 \ + ) \ + ) \ + : 0) #endif /* !A_WORKAROUND_REQUIRE_PROPAGATION */