Fix a memory leak when warning about malformed UTF-8 string
This commit is contained in:
parent
86fd404cb1
commit
98c121bf78
@ -0,0 +1,62 @@
|
|||||||
|
From dd0510590a1124f91ef2c615a64cd9bfbb245dd6 Mon Sep 17 00:00:00 2001
|
||||||
|
From: David Mitchell <davem@iabyn.com>
|
||||||
|
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ř <ppisar@redhat.com>
|
||||||
|
---
|
||||||
|
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
|
||||||
|
|
@ -306,6 +306,9 @@ Patch68: perl-5.29.9-avoid-leak-with-local-h-foo-a-n.patch
|
|||||||
# in upstream after 5.29.9
|
# in upstream after 5.29.9
|
||||||
Patch69: perl-5.28.1-perl-133892-coredump-in-Perl_re_intuit_start.patch
|
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
|
# 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
|
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
|
%patch67 -p1
|
||||||
%patch68 -p1
|
%patch68 -p1
|
||||||
%patch69 -p1
|
%patch69 -p1
|
||||||
|
%patch70 -p1
|
||||||
%patch200 -p1
|
%patch200 -p1
|
||||||
%patch201 -p1
|
%patch201 -p1
|
||||||
|
|
||||||
@ -2991,6 +2995,7 @@ perl -x patchlevel.h \
|
|||||||
'Fedora Patch66: Fix a memory leak in package name lookup (RT#133977)' \
|
'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 Patch68: Fix a memory leak when deletion in a tied hash dies' \
|
||||||
'Fedora Patch69: Fix a crash when matching case insensitively (RT#133892)' \
|
'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 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' \
|
'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \
|
||||||
%{nil}
|
%{nil}
|
||||||
@ -5293,6 +5298,7 @@ popd
|
|||||||
- Fix a memory leak in package name lookup (RT#133977)
|
- Fix a memory leak in package name lookup (RT#133977)
|
||||||
- Fix a memory leak when deletion in a tied hash dies
|
- Fix a memory leak when deletion in a tied hash dies
|
||||||
- Fix a crash when matching case insensitively (RT#133892)
|
- 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 <besser82@fedoraproject.org> - 4:5.28.1-434
|
* 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)
|
- Add explicit Requires: libxcrypt-devel to devel sub-package (bug #1666098)
|
||||||
|
Loading…
Reference in New Issue
Block a user