Subject: | Segfault with from_to |
The following code snippet causes a core dump or probably an internal
perl panic: panic: sv_setpvn called with negative strlen
at /usr/local/lib/perl5/5.8.0/i686-linux/Encode.pm line 184.
use Encode qw(from_to);
$value = bless {}, 'Bla';
Encode::from_to($value, "utf8", "iso-8859-1", Encode::FB_QUIET);
It seems to me that using SvEND causes this fatal error. For non PV scalars,
SvEND has no meaning. So fixes could be:
* all encode methods could croak for scalars not containing a PV (or
for scalars which do not contain a PV after applying SvPV on them)
or
* check whether the scalar has a PV and use SvEND, otherwise fallback to
an equivalent method to get the end of the string: e = s + slen (?)
Regards,
Slaven