cvs: ZendEngine2 / zend_execute.c zend_interfaces.c

From: Date: Tue, 04 Nov 2003 22:07:59 +0000
Subject: cvs: ZendEngine2 / zend_execute.c zend_interfaces.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-1960@lists.php.net to get a copy of this message
helly Tue Nov 4 17:07:59 2003 EDT Modified files: /ZendEngine2 zend_execute.c zend_interfaces.c Log: Prevent some SEGV's when Exceptions are thorown inside iterators. Index: ZendEngine2/zend_execute.c diff -u ZendEngine2/zend_execute.c:1.545 ZendEngine2/zend_execute.c:1.546 --- ZendEngine2/zend_execute.c:1.545 Wed Oct 22 15:59:58 2003 +++ ZendEngine2/zend_execute.c Tue Nov 4 17:07:59 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.c,v 1.545 2003/10/22 19:59:58 helly Exp $ */ +/* $Id: zend_execute.c,v 1.546 2003/11/04 22:07:59 helly Exp $ */ #define ZEND_INTENSIVE_DEBUGGING 0 @@ -2625,7 +2625,7 @@ } if (EG(This)) { - if (EG(exception) && EX(fbc)->common.fn_flags&ZEND_ACC_CTOR) { + if (EG(exception) && EX(fbc) && EX(fbc)->common.fn_flags&ZEND_ACC_CTOR) { EG(This)->refcount--; zval_ptr_dtor(&EG(This)); } else if (should_change_scope) { @@ -3632,7 +3632,8 @@ break; case ZEND_ITER_OBJECT: - if (iter->funcs->has_more(iter TSRMLS_CC) == FAILURE) { + /* !iter happens from exception */ + if (!iter || iter->funcs->has_more(iter TSRMLS_CC) == FAILURE) { /* reached end of iteration */ EX(opline) = op_array->opcodes+EX(opline)->op2.u.opline_num; return 0; /* CHECK_ME */ Index: ZendEngine2/zend_interfaces.c diff -u ZendEngine2/zend_interfaces.c:1.2 ZendEngine2/zend_interfaces.c:1.3 --- ZendEngine2/zend_interfaces.c:1.2 Tue Oct 28 13:46:37 2003 +++ ZendEngine2/zend_interfaces.c Tue Nov 4 17:07:59 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_interfaces.c,v 1.2 2003/10/28 18:46:37 helly Exp $ */ +/* $Id: zend_interfaces.c,v 1.3 2003/11/04 22:07:59 helly Exp $ */ #include "zend.h" #include "zend_API.h" @@ -131,16 +131,21 @@ /* {{{ zend_user_has_more */ static int zend_user_has_more(zend_object_iterator *_iter TSRMLS_DC) { - zend_user_iterator *iter = (zend_user_iterator*)_iter; - zval *object = (zval*)iter->it.data; - zval *more; - int result; - - zend_call_method_with_0_params(&object, iter->ce, &iter->ce->iterator_funcs.zf_has_more, "hasmore", &more); - result = i_zend_is_true(more); - zval_dtor(more); - FREE_ZVAL(more); - return result ? SUCCESS : FAILURE; + if (_iter) { + zend_user_iterator *iter = (zend_user_iterator*)_iter; + zval *object = (zval*)iter->it.data; + zval *more; + int result; + + zend_call_method_with_0_params(&object, iter->ce, &iter->ce->iterator_funcs.zf_has_more, "hasmore", &more); + if (more) { + result = i_zend_is_true(more); + zval_dtor(more); + FREE_ZVAL(more); + return result ? SUCCESS : FAILURE; + } + } + return FAILURE; } /* }}} */

« previous php.zend-engine.cvs (#1960) next »