diff options
author | Dmitry Stogov <dmitry@php.net> | 2005-04-27 06:47:08 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2005-04-27 06:47:08 +0000 |
commit | 28e68301dc63d0f61c226ca5c917a41ef2829247 (patch) | |
tree | 8c5d292a51c24d90733b7998533b1d95ca32a0e2 /Zend/tests/bug32674.phpt | |
parent | d30a9ee96d8bc129cf3370b8ecd0a8d76a2eec1a (diff) | |
download | php-git-28e68301dc63d0f61c226ca5c917a41ef2829247.tar.gz |
Fixed bug #32674 (exception in iterator causes crash)
Diffstat (limited to 'Zend/tests/bug32674.phpt')
-rw-r--r-- | Zend/tests/bug32674.phpt | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/Zend/tests/bug32674.phpt b/Zend/tests/bug32674.phpt new file mode 100644 index 0000000000..547bcec096 --- /dev/null +++ b/Zend/tests/bug32674.phpt @@ -0,0 +1,62 @@ +--TEST-- +Bug #32674 exception in iterator causes crash +--FILE-- +<?php +class collection implements Iterator { + + private $_elements = array(); + + public function __construct() { + } + + public function rewind() { + reset($this->_elements); + } + + public function count() { + return count($this->_elements); + } + + public function current() { + $element = current($this->_elements); + return $element; + } + + public function next() { + $element = next($this->_elements); + return $element; + } + + public function key() { + $this->_fillCollection(); + $element = key($this->_elements); + return $element; + } + + public function valid() { + throw new Exception('shit happend'); + + return ($this->current() !== false); + } +} + +class class2 { + public $dummy; +} + +$obj = new class2(); +$col = new collection(); + +try { + foreach($col as $co) { + //irrelevant + } + echo 'shouldn`t get here'; + //$dummy = 'this will not crash'; + $obj->dummy = 'this will crash'; +} catch (Exception $e) { + echo "ok\n"; +} +?> +--EXPECT-- +ok |