File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / Zend / tests / bug32674.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:47:52 2012 UTC (13 years, 1 month ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

    1: --TEST--
    2: Bug #32674 (exception in iterator causes crash)
    3: --FILE--
    4: <?php
    5: class collection implements Iterator {
    6: 
    7:   private $_elements = array();
    8: 
    9:   public function __construct() {
   10:   }
   11: 
   12:   public function rewind() {
   13:     reset($this->_elements);
   14:   }
   15: 
   16:   public function count() {
   17:     return count($this->_elements);
   18:   }
   19: 
   20:   public function current() {
   21:     $element = current($this->_elements);
   22:     return $element;
   23:   }
   24: 
   25:   public function next() {
   26:     $element = next($this->_elements);
   27:     return $element;
   28:   }
   29: 
   30:   public function key() {
   31:     $this->_fillCollection();
   32:     $element = key($this->_elements);
   33:     return $element;
   34:   }
   35: 
   36:   public function valid() {
   37:     throw new Exception('shit happend');
   38: 
   39:     return ($this->current() !== false);
   40:   }
   41: }
   42: 
   43: class class2 {
   44:   public $dummy;
   45: }
   46: 
   47: $obj = new class2();
   48: $col = new collection();
   49: 
   50: try {
   51: 	foreach($col as $co) {
   52:   	//irrelevant
   53: 	}
   54: 	echo 'shouldn`t get here';
   55: 	//$dummy = 'this will not crash'; 
   56: 	$obj->dummy = 'this will crash';
   57: } catch (Exception $e) {
   58: 	echo "ok\n";
   59: }
   60: ?>
   61: --EXPECT--
   62: ok

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>