SvLEN==0 means the scalar does not own the buffer.
PERL_OLD_COPY_ON_WRITE can’t do its copy-on-write with those, as
SvIsCOW && SvLEN==0 means a shared hash key scalar.
PerlIO::encoding passes such scalars to the Encode object’s
encode method.
Why am I even fixing this? I was trying to make sure that I wasn’t
breaking PERL_OLD_COPY_ON_WRITE with other changes. I got assertion
failures from encoding.t so I looked to see what the problem might be,
thinking it could affect other configurations. It turns out not to be
specific to PERL_OLD_COPY_ON_WRITE, but since I have found the problem
I might as well fix it anyway.
? (!((sflags & CAN_COW_MASK) == CAN_COW_FLAGS
# ifdef PERL_OLD_COPY_ON_WRITE
&& (SvFLAGS(dstr) & CAN_COW_MASK) == CAN_COW_FLAGS
- && SvTYPE(sstr) >= SVt_PVIV
+ && SvTYPE(sstr) >= SVt_PVIV && len
# else
&& !(SvFLAGS(dstr) & SVf_BREAK)
&& !(sflags & SVf_IsCOW)