]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-5.6'
authorNikita Popov <nikic@php.net>
Thu, 11 Jun 2015 15:44:51 +0000 (17:44 +0200)
committerNikita Popov <nikic@php.net>
Thu, 11 Jun 2015 15:44:51 +0000 (17:44 +0200)
Conflicts:
Zend/zend_generators.c

1  2 
Zend/tests/bug69740.phpt
Zend/zend_generators.c

index 0000000000000000000000000000000000000000,30a2a49099080de11519cb5ed4cf33857da76504..c8910b22d8dbfd921fca265b0bb7d806d70a01d2
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,28 +1,28 @@@
 -Fatal error: Uncaught exception 'Exception' in %s:%d
+ --TEST--
+ Bug #69740: finally in generator (yield) swallows exception in iteration
+ --FILE--
+ <?php
+ function generate() {
+     try {
+         yield 1;
+         yield 2;
+     } finally {
+         echo "finally\n";
+     }
+ }
+ foreach (generate() as $i) {
+     echo $i, "\n";
+     throw new Exception();
+ }
+ ?>
+ --EXPECTF--
+ 1
+ finally
++Fatal error: Uncaught Exception in %s:%d
+ Stack trace:
+ #0 {main}
+   thrown in %s on line %d
index 706d913f72c7506021c327801e622ef19ad1a089,1cf9566ea556589ecbb2508a668ed295d576e576..13304e9fddbce5a5cf09d11812bf74b526f8ad2d
@@@ -174,13 -196,13 +174,15 @@@ static void zend_generator_dtor_storage
        /* If a finally block was found we jump directly to it and
         * resume the generator. */
        if (finally_op_num) {
 -              ex->opline = &ex->op_array->opcodes[finally_op_num];
 -              ex->fast_ret = NULL;
 -              ex->delayed_exception = EG(exception);
 +              zval *fast_call = ZEND_CALL_VAR(ex, ex->func->op_array.opcodes[finally_op_end].op1.var);
 +
-               Z_OBJ_P(fast_call) = NULL;
++              Z_OBJ_P(fast_call) = EG(exception);
+               EG(exception) = NULL;
 +              fast_call->u2.lineno = (uint32_t)-1;
 +              ex->opline = &ex->func->op_array.opcodes[finally_op_num];
                generator->flags |= ZEND_GENERATOR_FORCED_CLOSE;
 -              zend_generator_resume(generator TSRMLS_CC);
 +              zend_generator_resume(generator);
        }
  }
  /* }}} */