Blame SOURCES/perl-5.16.3-Don-t-leak-deleted-iterator-when-tying-hash.patch
|
|
734417 |
From 677ffc8fe97148750054b11e7fbd21c98f860ee1 Mon Sep 17 00:00:00 2001
|
|
|
734417 |
From: Father Chrysostomos <sprout@cpan.org>
|
|
|
734417 |
Date: Fri, 21 Sep 2012 18:23:20 -0700
|
|
|
734417 |
Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20leak=20deleted=20iterator=20whe?=
|
|
|
734417 |
=?UTF-8?q?n=20tying=20hash?=
|
|
|
734417 |
MIME-Version: 1.0
|
|
|
734417 |
Content-Type: text/plain; charset=UTF-8
|
|
|
734417 |
Content-Transfer-Encoding: 8bit
|
|
|
734417 |
|
|
|
734417 |
Petr Pisar: ported to 5.16.3
|
|
|
734417 |
---
|
|
|
734417 |
pp_sys.c | 7 +++++++
|
|
|
734417 |
t/op/tie.t | 13 +++++++++++++
|
|
|
734417 |
2 files changed, 20 insertions(+)
|
|
|
734417 |
|
|
|
734417 |
diff --git a/pp_sys.c b/pp_sys.c
|
|
|
734417 |
index 034a2d0..0e35d59 100644
|
|
|
734417 |
--- a/pp_sys.c
|
|
|
734417 |
+++ b/pp_sys.c
|
|
|
734417 |
@@ -852,9 +852,16 @@ PP(pp_tie)
|
|
|
734417 |
|
|
|
734417 |
switch(SvTYPE(varsv)) {
|
|
|
734417 |
case SVt_PVHV:
|
|
|
734417 |
+ {
|
|
|
734417 |
+ HE *entry;
|
|
|
734417 |
methname = "TIEHASH";
|
|
|
734417 |
+ if (HvLAZYDEL(varsv) && (entry = HvEITER((HV *)varsv))) {
|
|
|
734417 |
+ HvLAZYDEL_off(varsv);
|
|
|
734417 |
+ hv_free_ent((HV *)varsv, entry);
|
|
|
734417 |
+ }
|
|
|
734417 |
HvEITER_set(MUTABLE_HV(varsv), 0);
|
|
|
734417 |
break;
|
|
|
734417 |
+ }
|
|
|
734417 |
case SVt_PVAV:
|
|
|
734417 |
methname = "TIEARRAY";
|
|
|
734417 |
if (!AvREAL(varsv)) {
|
|
|
734417 |
diff --git a/t/op/tie.t b/t/op/tie.t
|
|
|
734417 |
index 9301bb3..5a536b8 100644
|
|
|
734417 |
--- a/t/op/tie.t
|
|
|
734417 |
+++ b/t/op/tie.t
|
|
|
734417 |
@@ -1259,3 +1259,16 @@ $h{i}{j} = 'k';
|
|
|
734417 |
print $h{i}{j}, "\n";
|
|
|
734417 |
EXPECT
|
|
|
734417 |
k
|
|
|
734417 |
+########
|
|
|
734417 |
+
|
|
|
734417 |
+# NAME Test that tying a hash does not leak a deleted iterator
|
|
|
734417 |
+# This produced unbalanced string table warnings under
|
|
|
734417 |
+# PERL_DESTRUCT_LEVEL=2.
|
|
|
734417 |
+package l {
|
|
|
734417 |
+ sub TIEHASH{bless[]}
|
|
|
734417 |
+}
|
|
|
734417 |
+$h = {foo=>0};
|
|
|
734417 |
+each %$h;
|
|
|
734417 |
+delete $$h{foo};
|
|
|
734417 |
+tie %$h, 'l';
|
|
|
734417 |
+EXPECT
|
|
|
734417 |
--
|
|
|
734417 |
1.8.1.4
|
|
|
734417 |
|