Merge branch 'PHP-5.6' into PHP-7.0

Conflicts:
	Zend/zend_exceptions.c
This commit is contained in:
Xinchen Hui 2015-11-20 16:38:00 +08:00
commit a2e4e64682
2 changed files with 25 additions and 1 deletions

16
Zend/tests/bug70944.phpt Normal file
View file

@ -0,0 +1,16 @@
--TEST--
Bug #70944 (try{ } finally{} can create infinite chains of exceptions)
--FILE--
<?php
$e = new Exception("Bar");
try {
throw new Exception("Foo", 0, $e);
} finally {
throw $e;
}
?>
--EXPECTF--
Fatal error: Uncaught Exception: Bar in %sbug70944.php:%d
Stack trace:
#0 {main}
thrown in %sbug70944.php on line %d

View file

@ -70,7 +70,8 @@ ZEND_API zend_class_entry *zend_get_exception_base(zval *object)
void zend_exception_set_previous(zend_object *exception, zend_object *add_previous)
{
zval tmp, *previous, zv, *pzv, rv;
zval *previous, *pzv;
zval tmp, zv, rv;
zend_class_entry *base_ce;
if (exception == add_previous || !add_previous || !exception) {
@ -81,6 +82,13 @@ void zend_exception_set_previous(zend_object *exception, zend_object *add_previo
zend_error_noreturn(E_CORE_ERROR, "Previous exception must implement Throwable");
return;
}
pzv = zend_read_property(i_get_exception_base(&tmp), &tmp, "previous", sizeof("previous")-1, 1, &rv);
while (Z_TYPE_P(pzv) == IS_OBJECT) {
if (Z_OBJ_P(pzv) == exception) {
return;
}
pzv = zend_read_property(i_get_exception_base(pzv), pzv, "previous", sizeof("previous")-1, 1, &rv);
}
ZVAL_OBJ(&zv, exception);
pzv = &zv;
do {