Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Prevent some SEGV's when Exceptions are thorown inside iterators.

  • Loading branch information...
commit f9d13098e732e89873d49353c2dd901dd11aa583 1 parent e912635
Marcus Boerger authored
Showing with 18 additions and 12 deletions.
  1. +3 −2 Zend/zend_execute.c
  2. +15 −10 Zend/zend_interfaces.c
View
5 Zend/zend_execute.c
@@ -2625,7 +2625,7 @@ int zend_do_fcall_common_helper(ZEND_OPCODE_HANDLER_ARGS)
}
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 @@ int zend_fe_fetch_handler(ZEND_OPCODE_HANDLER_ARGS)
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 */
View
25 Zend/zend_interfaces.c
@@ -131,16 +131,21 @@ static void zend_user_dtor(zend_object_iterator *_iter TSRMLS_DC)
/* {{{ 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;
}
/* }}} */
Please sign in to comment.
Something went wrong with that request. Please try again.