From 05bb37c0365d601510de568b916caa702a67cd77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= Date: Fri, 5 Apr 2019 17:11:59 +0200 Subject: [PATCH] Fix a memory leak when assignig to a localized ${^WARNING_BITS} --- ...9.9-fix-leak-with-local-WARNING_BITS.patch | 39 +++++++++++++++++++ perl.spec | 7 ++++ 2 files changed, 46 insertions(+) create mode 100644 perl-5.29.9-fix-leak-with-local-WARNING_BITS.patch diff --git a/perl-5.29.9-fix-leak-with-local-WARNING_BITS.patch b/perl-5.29.9-fix-leak-with-local-WARNING_BITS.patch new file mode 100644 index 0000000..ec4b0fe --- /dev/null +++ b/perl-5.29.9-fix-leak-with-local-WARNING_BITS.patch @@ -0,0 +1,39 @@ +From 1113f30d91f662c876a07b357666f02f04a30a75 Mon Sep 17 00:00:00 2001 +From: David Mitchell +Date: Mon, 25 Mar 2019 17:18:58 +0000 +Subject: [PATCH] fix leak with local ${^WARNING_BITS} = ... +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When restoring the old value, need to free the current value first. +Can be reproduced with + + { + local ${^WARNING_BITS} = 'swit'; + } + +when run under ASan or similar. +An equivalent test already exists in t/op/leaky-magic.t. + +Signed-off-by: Petr Písař +--- + mg.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/mg.c b/mg.c +index b022d63442..320e2d39bb 100644 +--- a/mg.c ++++ b/mg.c +@@ -2916,6 +2916,8 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) + else if (strEQ(mg->mg_ptr+1, "ARNING_BITS")) { + if ( ! (PL_dowarn & G_WARN_ALL_MASK)) { + if (!SvPOK(sv)) { ++ if (!specialWARN(PL_compiling.cop_warnings)) ++ PerlMemShared_free(PL_compiling.cop_warnings); + PL_compiling.cop_warnings = pWARN_STD; + break; + } +-- +2.20.1 + diff --git a/perl.spec b/perl.spec index a6ed5d4..12471cf 100644 --- a/perl.spec +++ b/perl.spec @@ -287,6 +287,10 @@ Patch62: perl-5.29.9-fix-leak-in-BEGIN-threads-new.patch # string, in upstream after 5.29.9 Patch63: perl-5.29.9-avoid-leak-assigning-regexp-to-non-COW-string.patch +# Fix a memory leak when assignig to a localized ${^WARNING_BITS}, +# in upstream after 5.29.9 +Patch64: perl-5.29.9-fix-leak-with-local-WARNING_BITS.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 @@ -2906,6 +2910,7 @@ Perl extension for Version Objects %patch61 -p1 %patch62 -p1 %patch63 -p1 +%patch64 -p1 %patch200 -p1 %patch201 -p1 @@ -2961,6 +2966,7 @@ perl -x patchlevel.h \ 'Fedora Patch61: Fix a memory leak when cloning a regular expression' \ 'Fedora Patch62: Fix a memory leak when spawning threads in a BEGIN phase' \ 'Fedora Patch63: Fix a memory leak when assigning a regular expression to a non-copy-on-write string' \ + 'Fedora Patch64: Fix a memory leak when assignig to a localized ${^WARNING_BITS}' \ '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} @@ -5258,6 +5264,7 @@ popd - Fix a memory leak when cloning a regular expression - Fix a memory leak when spawning threads in a BEGIN phase - Fix a memory leak when assigning a regular expression to a non-copy-on-write string +- Fix a memory leak when assignig to a localized ${^WARNING_BITS} * Tue Mar 05 2019 Björn Esser - 4:5.28.1-434 - Add explicit Requires: libxcrypt-devel to devel sub-package (bug #1666098)