Fix a memory leak when assignig to a localized ${^WARNING_BITS}

This commit is contained in:
Petr Písař 2019-04-05 17:11:59 +02:00
parent 4681935eb5
commit 05bb37c036
2 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,39 @@
From 1113f30d91f662c876a07b357666f02f04a30a75 Mon Sep 17 00:00:00 2001
From: David Mitchell <davem@iabyn.com>
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ř <ppisar@redhat.com>
---
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

View File

@ -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 <besser82@fedoraproject.org> - 4:5.28.1-434
- Add explicit Requires: libxcrypt-devel to devel sub-package (bug #1666098)