summaryrefslogtreecommitdiff
path: root/ext/spl/tests/filesystemiterator_leak.phpt
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-02-15 10:36:48 +0100
committerNikita Popov <nikita.ppv@gmail.com>2021-02-15 10:37:59 +0100
commit44a80b64b918ff64a4e5bbcef43f00dfe0fcde27 (patch)
tree5e2454ccfe6aeaf9e68f380fe6a3d53ef87d1391 /ext/spl/tests/filesystemiterator_leak.phpt
parentc34c5234678a5898c1796983e9ca8faa293f3fe3 (diff)
downloadphp-git-44a80b64b918ff64a4e5bbcef43f00dfe0fcde27.tar.gz
Fix leak when breaking out of FilesystemIterator
We need to always destroy current, not just when iter.data is not set. Take this opportunity to clean up the iterator destructor code a bit, to remove redundant checks and incorrect comments.
Diffstat (limited to 'ext/spl/tests/filesystemiterator_leak.phpt')
-rw-r--r--ext/spl/tests/filesystemiterator_leak.phpt12
1 files changed, 12 insertions, 0 deletions
diff --git a/ext/spl/tests/filesystemiterator_leak.phpt b/ext/spl/tests/filesystemiterator_leak.phpt
new file mode 100644
index 0000000000..9cdaeaaa3a
--- /dev/null
+++ b/ext/spl/tests/filesystemiterator_leak.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Don't leak when breaking from FilesystemIterator
+--FILE--
+<?php
+$iterator = new FilesystemIterator(__DIR__);
+foreach ($iterator as $value) {
+ break;
+}
+?>
+===DONE===
+--EXPECT--
+===DONE===