Fix a memory leak in B::RHE->HASH method

This commit is contained in:
Petr Písař 2017-01-26 13:12:39 +01:00
parent de55dc7e45
commit d1db9a0791
2 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,65 @@
From 3c38abae50c05c6f3c9f7eca561ec08c62fba1ba Mon Sep 17 00:00:00 2001
From: Sergey Aleynikov <sergey.aleynikov@gmail.com>
Date: Thu, 5 Jan 2017 01:33:32 +0300
Subject: [PATCH] Fix memory leak in B::RHE->HASH method.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Petr Písař: Ported to 5.24.1:
commit 4b6e9aa6aa2256da1ec7ed08f819cbf5d1463741
Author: Sergey Aleynikov <sergey.aleynikov@gmail.com>
Date: Thu Jan 5 01:33:32 2017 +0300
Fix memory leak in B::RHE->HASH method.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
ext/B/B.xs | 2 +-
t/op/svleak.t | 12 +++++++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/ext/B/B.xs b/ext/B/B.xs
index b4b6a40..e859d7d 100644
--- a/ext/B/B.xs
+++ b/ext/B/B.xs
@@ -2179,7 +2179,7 @@ SV*
HASH(h)
B::RHE h
CODE:
- RETVAL = newRV( (SV*)cophh_2hv(h, 0) );
+ RETVAL = newRV_noinc( (SV*)cophh_2hv(h, 0) );
OUTPUT:
RETVAL
diff --git a/t/op/svleak.t b/t/op/svleak.t
index c18f498..b0692ff 100644
--- a/t/op/svleak.t
+++ b/t/op/svleak.t
@@ -15,7 +15,7 @@ BEGIN {
use Config;
-plan tests => 132;
+plan tests => 133;
# run some code N times. If the number of SVs at the end of loop N is
# greater than (N-1)*delta at the end of loop 1, we've got a leak
@@ -547,3 +547,13 @@ EOF
sub f { $a =~ /[^.]+$b/; }
::leak(2, 0, \&f, q{use re 'strict' shouldn't leak warning strings});
}
+
+# check that B::RHE->HASH does not leak
+{
+ package BHINT;
+ sub foo {}
+ require B;
+ my $op = B::svref_2object(\&foo)->ROOT->first;
+ sub lk { { my $d = $op->hints_hash->HASH } }
+ ::leak(3, 0, \&lk, q!B::RHE->HASH shoudln't leak!);
+}
--
2.7.4

View File

@ -262,6 +262,9 @@ Patch72: perl-5.25.4-perl-129287-Make-UTF8-append-null.patch
# Fix recreation of *::, RT#129869, in upstream after 5.25.9
Patch73: perl-5.24.1-fix-special-case-recreation-of.patch
# Fix a memory leak in B::RHE->HASH method, RT#130504, in upstream after 5.25.9
Patch74: perl-5.24.1-Fix-memory-leak-in-B-RHE-HASH-method.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
@ -2959,6 +2962,7 @@ Perl extension for Version Objects
%patch71 -p1
%patch72 -p1
%patch73 -p1
%patch74 -p1
%patch200 -p1
%patch201 -p1
@ -3020,6 +3024,7 @@ perl -x patchlevel.h \
'Fedora Patch71: Fix out-of-bound read in case of unmatched regexp backreference (RT#129377)' \
'Fedora Patch72: Fix UTF-8 string handling in & operator (RT#129287)' \
'Fedora Patch73: Fix recreation of *:: (RT#129869)' \
'Fedora Patch74: Fix a memory leak in B::RHE->HASH method (RT#130504)' \
'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}
@ -5299,6 +5304,7 @@ popd
* Thu Jan 26 2017 Petr Pisar <ppisar@redhat.com> - 4:5.24.1-387
- Fix UTF-8 string handling in & operator (RT#129287)
- Fix recreation of *:: (RT#129869)
- Fix a memory leak in B::RHE->HASH method (RT#130504)
* Fri Jan 20 2017 Petr Pisar <ppisar@redhat.com> - 4:5.24.1-386
- Fix a buffer overflow in split in scalar context (RT#130262)