diff --git a/perl-5.29.9-fix-leak-in-Perl__force_out_malformed_utf8_message.patch b/perl-5.29.9-fix-leak-in-Perl__force_out_malformed_utf8_message.patch new file mode 100644 index 0000000..8b919c4 --- /dev/null +++ b/perl-5.29.9-fix-leak-in-Perl__force_out_malformed_utf8_message.patch @@ -0,0 +1,62 @@ +From dd0510590a1124f91ef2c615a64cd9bfbb245dd6 Mon Sep 17 00:00:00 2001 +From: David Mitchell +Date: Tue, 26 Mar 2019 14:58:04 +0000 +Subject: [PATCH] fix leak in Perl__force_out_malformed_utf8_message() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This function temporarily sets PL_curcop->cop_warnings to pWARN_ALL in +order to enforce mandatory warnings about malformed utf8, but it +didn't restore cop_warnings, so the old value leaked. + +Can be reproduced with, e.g. + + no warnings 'utf8'; + CORE::evalbytes qq{ use utf8; "\\N{abc\x{c0}}"}; + +which is already exercised in t/uni/parser.t. + +Signed-off-by: Petr Písař +--- + utf8.c | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +diff --git a/utf8.c b/utf8.c +index e479400b71..84db2f6aee 100644 +--- a/utf8.c ++++ b/utf8.c +@@ -53,6 +53,19 @@ within non-zero characters. + =cut + */ + ++/* helper for Perl__force_out_malformed_utf8_message(). Like ++ * SAVECOMPILEWARNINGS(), but works with PL_curcop rather than ++ * PL_compiling */ ++ ++static void ++S_restore_cop_warnings(pTHX_ void *p) ++{ ++ if (!specialWARN(PL_curcop->cop_warnings)) ++ PerlMemShared_free(PL_curcop->cop_warnings); ++ PL_curcop->cop_warnings = (STRLEN*)p; ++} ++ ++ + void + Perl__force_out_malformed_utf8_message(pTHX_ + const U8 *const p, /* First byte in UTF-8 sequence */ +@@ -84,6 +97,10 @@ Perl__force_out_malformed_utf8_message(pTHX_ + + PL_dowarn = G_WARN_ALL_ON|G_WARN_ON; + if (PL_curcop) { ++ /* this is like SAVECOMPILEWARNINGS() except with PL_curcop rather ++ * than PL_compiling */ ++ SAVEDESTRUCTOR_X(S_restore_cop_warnings, ++ (void*)PL_curcop->cop_warnings); + PL_curcop->cop_warnings = pWARN_ALL; + } + +-- +2.20.1 + diff --git a/perl.spec b/perl.spec index b9517ed..fa4a061 100644 --- a/perl.spec +++ b/perl.spec @@ -306,6 +306,9 @@ Patch68: perl-5.29.9-avoid-leak-with-local-h-foo-a-n.patch # in upstream after 5.29.9 Patch69: perl-5.28.1-perl-133892-coredump-in-Perl_re_intuit_start.patch +# Fix a memory leak when warning about malformed UTF-8 string +Patch70: perl-5.29.9-fix-leak-in-Perl__force_out_malformed_utf8_message.patch + # Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048 Patch200: perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch @@ -2931,6 +2934,7 @@ Perl extension for Version Objects %patch67 -p1 %patch68 -p1 %patch69 -p1 +%patch70 -p1 %patch200 -p1 %patch201 -p1 @@ -2991,6 +2995,7 @@ perl -x patchlevel.h \ 'Fedora Patch66: Fix a memory leak in package name lookup (RT#133977)' \ 'Fedora Patch68: Fix a memory leak when deletion in a tied hash dies' \ 'Fedora Patch69: Fix a crash when matching case insensitively (RT#133892)' \ + 'Fedora Patch70: Fix a memory leak when warning about malformed UTF-8 string' \ 'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux' \ 'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \ %{nil} @@ -5293,6 +5298,7 @@ popd - Fix a memory leak in package name lookup (RT#133977) - Fix a memory leak when deletion in a tied hash dies - Fix a crash when matching case insensitively (RT#133892) +- Fix a memory leak when warning about malformed UTF-8 string * Tue Mar 05 2019 Björn Esser - 4:5.28.1-434 - Add explicit Requires: libxcrypt-devel to devel sub-package (bug #1666098)