diff --git a/Encode-2.86-Fix-panic-when-encoding-undef-scalars.patch b/Encode-2.86-Fix-panic-when-encoding-undef-scalars.patch new file mode 100644 index 0000000..4e522c2 --- /dev/null +++ b/Encode-2.86-Fix-panic-when-encoding-undef-scalars.patch @@ -0,0 +1,47 @@ +From 519fb7e761447245fed9bb2de02e894b71ccae2f Mon Sep 17 00:00:00 2001 +From: Vincent van Dam +Date: Thu, 22 Sep 2016 14:48:05 +0200 +Subject: [PATCH] Fix panic when encoding undef scalars +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Petr Písař +--- + lib/Encode/Encoder.pm | 4 +++- + t/undef.t | 8 ++++++++ + 2 files changed, 11 insertions(+), 1 deletion(-) + create mode 100644 t/undef.t + +diff --git a/lib/Encode/Encoder.pm b/lib/Encode/Encoder.pm +index 23e0349..fef4e9b 100644 +--- a/lib/Encode/Encoder.pm ++++ b/lib/Encode/Encoder.pm +@@ -85,7 +85,9 @@ sub AUTOLOAD { + from_to( $self->{data}, $self->{encoding}, $obj->name, 1 ); + } + else { +- $self->{data} = $obj->encode( $self->{data}, 1 ); ++ if ( defined($self->{data}) ) { ++ $self->{data} = $obj->encode( $self->{data}, 1 ); ++ } + } + $self->{encoding} = $obj->name; + return $self; +diff --git a/t/undef.t b/t/undef.t +new file mode 100644 +index 0000000..ad8bcd6 +--- /dev/null ++++ b/t/undef.t +@@ -0,0 +1,8 @@ ++use Encode::Encoder qw(encoder); ++ ++use Test::More; ++plan tests => 1; ++ ++my $emptyutf8; ++eval { $c = encoder($emptyutf8)->utf8; }; ++ok(!$@,"crashed encoding undef variable ($@)"); +-- +2.7.4 + diff --git a/perl-Encode.spec b/perl-Encode.spec index 5da3294..8565ded 100644 --- a/perl-Encode.spec +++ b/perl-Encode.spec @@ -32,6 +32,9 @@ Patch3: Encode-2.86-Encode-utf8-Check-for-overflowed-and-overlong-UTF-8- # 3/3 Refusing non-shortests UTF-8 representations, # , in upstream after 2.86 Patch4: Encode-2.86-Encode-utf8-Fix-count-of-replacement-characters-for-.patch +# Fix panic when encoding undefined scalars, +# , in upstream after 2.86 +Patch5: Encode-2.86-Fix-panic-when-encoding-undef-scalars.patch BuildRequires: coreutils BuildRequires: findutils BuildRequires: make @@ -147,6 +150,7 @@ your own encoding to perl. No knowledge of XS is necessary. %patch2 -p1 %patch3 -p1 %patch4 -p1 +%patch5 -p1 %build # Additional scripts can be installed by appending MORE_SCRIPTS, UCM files by @@ -191,6 +195,7 @@ make test * Fri Sep 30 2016 Petr Pisar - 4:2.86-3 - Fix Encode::encode_utf8(undef) to return undef (CPAN RT#116904) - Refuse non-shortests UTF-8 representations in strict mode +- Fix panic when encoding undefined scalars * Fri Sep 16 2016 Petr Pisar - 4:2.86-2 - Add Artistic 2.0 into license tag because of encguess tool