Subject: | Deep recursion error finding invalid charset |
Encode::find_encoding() of a charset with lots of spaces causes a perl
stack overflow.
Test case attached to this ticket.
Subject: | badcharset.t |
#!/bin/perl
use Test::More no_plan;
use strict;
use warnings;
use Encode;
sub backtrace(;$) {
my $level = shift() || 1;
my $rv = '';
my ($last_package, undef, $last_line) = caller(++$level);
my ($package, $line, $subroutine);
while (($package, undef, $line, $subroutine) = caller(++$level)) {
$subroutine = $last_package . $subroutine if ($subroutine =~ /^\(/);
$rv .= " " if ($rv);
$rv .= "${subroutine}[$last_line]";
$last_package = $package;
$last_line = $line;
}
return $rv;
}
{
local $SIG{__WARN__} = sub { fail("warning: $_[0]"); diag(backtrace()."\n")};
my $decoder = Encode::find_encoding('x'.(" x" x 1000));
}