From: Dmitry Stogov Date: Mon, 6 Jun 2005 08:24:05 +0000 (+0000) Subject: Fixed bug #32993 (implemented Iterator function current() don't throw exception) X-Git-Tag: php-5.0.1b1~77 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=61054dbcd0a27ae7cc4785bf93331ddf77261698;p=php Fixed bug #32993 (implemented Iterator function current() don't throw exception) --- diff --git a/NEWS b/NEWS index 7392e0567c..d7e1a520ca 100644 --- a/NEWS +++ b/NEWS @@ -120,6 +120,8 @@ PHP NEWS - Fixed bug with $HTTP_RAW_POST_DATA not getting set. (Brian) - Fixed bug in mysql::client_version(). (Georg) - Fixed ZTS destruction. (Marcus) +- Fixed bug #32993 (implemented Iterator function current() don't throw + exception). (Dmitry) - Fixed bug #32924 (file included with "auto_prepend_file" can be included with require_once() or include_once()). (Stas) - Fixed bug #32833 (Invalid opcode). (Dmitry) diff --git a/Zend/tests/bug32993.phpt b/Zend/tests/bug32993.phpt new file mode 100755 index 0000000000..88fb0230b6 --- /dev/null +++ b/Zend/tests/bug32993.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #32993 (implemented Iterator function current() don't throw exception) +--FILE-- +arr); } + public function current() { throw new Exception(); } + public function key() { return key($this->arr); } + public function next() { return next($this->arr); } + public function valid() { return (current($this->arr) !== false); } +} + +$t = new Test(); +$t->arr = array(1, 2, 3); + +try { + foreach ($t as $v) { + echo "$v\n"; + } +} catch (Exception $e) { + ; // handle exception +} +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index c5a5e032ae..01610c2027 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -3110,13 +3110,13 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY) ZEND_VM_CONTINUE_JMP(); } iter->funcs->get_current_data(iter, &value TSRMLS_CC); + if (EG(exception)) { + array->refcount--; + zval_ptr_dtor(&array); + ZEND_VM_NEXT_OPCODE(); + } if (!value) { /* failure in get_current_data */ - if (EG(exception)) { - array->refcount--; - zval_ptr_dtor(&array); - ZEND_VM_NEXT_OPCODE(); - } ZEND_VM_SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); ZEND_VM_CONTINUE_JMP(); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 173b5f120f..7b71bcd9d4 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -7667,13 +7667,13 @@ static int ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) ZEND_VM_CONTINUE_JMP(); } iter->funcs->get_current_data(iter, &value TSRMLS_CC); + if (EG(exception)) { + array->refcount--; + zval_ptr_dtor(&array); + ZEND_VM_NEXT_OPCODE(); + } if (!value) { /* failure in get_current_data */ - if (EG(exception)) { - array->refcount--; - zval_ptr_dtor(&array); - ZEND_VM_NEXT_OPCODE(); - } ZEND_VM_SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); ZEND_VM_CONTINUE_JMP(); } @@ -32793,13 +32793,13 @@ static int ZEND_FE_FETCH_HANDLER(ZEND_OPCODE_HANDLER_ARGS) ZEND_VM_CONTINUE_JMP(); } iter->funcs->get_current_data(iter, &value TSRMLS_CC); + if (EG(exception)) { + array->refcount--; + zval_ptr_dtor(&array); + ZEND_VM_NEXT_OPCODE(); + } if (!value) { /* failure in get_current_data */ - if (EG(exception)) { - array->refcount--; - zval_ptr_dtor(&array); - ZEND_VM_NEXT_OPCODE(); - } ZEND_VM_SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); ZEND_VM_CONTINUE_JMP(); }