summaryrefslogtreecommitdiff
path: root/Zend/tests/foreach_empty_loop_leak.phpt
blob: 70b391181b9307fb84b3024755c9f69dcb9b7f37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
--TEST--
Empty foreach loops with exception must not leak
--FILE--
<?php

class Foo implements IteratorAggregate {
    public function getIterator() {
        return new ArrayIterator([]);
    }
    public function __destruct() {
        throw new Exception;
    }
}

try {
    foreach (new Foo as $x);
} catch (Exception $e) {
    echo "Exception caught\n";
}

?>
--EXPECT--
Exception caught