diff --git a/perl-5.28.1-fix-a-leak-with-indented-heredocs.patch b/perl-5.28.1-fix-a-leak-with-indented-heredocs.patch new file mode 100644 index 0000000..d95db9c --- /dev/null +++ b/perl-5.28.1-fix-a-leak-with-indented-heredocs.patch @@ -0,0 +1,53 @@ +From a83eb62d86a48741cbe2decf2bd99ef5292d1c02 Mon Sep 17 00:00:00 2001 +From: David Mitchell +Date: Mon, 25 Mar 2019 20:13:30 +0000 +Subject: [PATCH] fix a leak with indented heredocs +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +With something like + + |print <<~EOF; + | some data + | EOF + +it croaks (as it should) with "Indentation ... doesn't match delimiter", +but in that case it leaks the recently malloc()d 'indent' buffer. + +The fix is simple. I've also fixed by code inspection where the code +does 'goto interminable', although I didn't try to reproduce the conditions +where the goto might occur. + +Petr Písař: Ported to 5.28.1 from +e40cca748f05c81e1929ed625407afbe7c79d4dd/ + +Signed-off-by: Petr Písař +--- + toke.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/toke.c b/toke.c +index 4747ef5..240fd49 100644 +--- a/toke.c ++++ b/toke.c +@@ -10365,6 +10365,7 @@ S_scan_heredoc(pTHX_ char *s) + + /* Line doesn't begin with our indentation? Croak */ + } else { ++ Safefree(indent); + Perl_croak(aTHX_ + "Indentation on line %d of here-doc doesn't match delimiter", + (int)linecount +@@ -10388,6 +10389,8 @@ S_scan_heredoc(pTHX_ char *s) + return s; + + interminable: ++ if (indent) ++ Safefree(indent); + SvREFCNT_dec(tmpstr); + CopLINE_set(PL_curcop, origline); + missingterm(PL_tokenbuf + 1, sizeof(PL_tokenbuf) - 1); +-- +2.20.1 + diff --git a/perl.spec b/perl.spec index 12471cf..6d7d135 100644 --- a/perl.spec +++ b/perl.spec @@ -291,6 +291,10 @@ Patch63: perl-5.29.9-avoid-leak-assigning-regexp-to-non-COW-string.patch # in upstream after 5.29.9 Patch64: perl-5.29.9-fix-leak-with-local-WARNING_BITS.patch +# Fix a memory leak when parsing misindented here-documents, +# in upstream after 5.29.9 +Patch65: perl-5.28.1-fix-a-leak-with-indented-heredocs.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 @@ -2911,6 +2915,7 @@ Perl extension for Version Objects %patch62 -p1 %patch63 -p1 %patch64 -p1 +%patch65 -p1 %patch200 -p1 %patch201 -p1 @@ -2967,6 +2972,7 @@ perl -x patchlevel.h \ '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 Patch65: Fix a memory leak when parsing misindented here-documents' \ '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} @@ -5265,6 +5271,7 @@ popd - 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} +- Fix a memory leak when parsing misindented here-documents * Tue Mar 05 2019 Björn Esser - 4:5.28.1-434 - Add explicit Requires: libxcrypt-devel to devel sub-package (bug #1666098)