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