com php-src: Merge branch 'PHP-5.6' into PHP-7.0: Zend/tests/bug70944.phpt Zend/zend_exceptions.c

From: Date: Thu, 19 Nov 2015 18:25:05 +0000
Subject: com php-src: Merge branch 'PHP-5.6' into PHP-7.0: Zend/tests/bug70944.phpt Zend/zend_exceptions.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-89936@lists.php.net to get a copy of this message
Commit: cbb3f7f15ac95ec173498391382910f82622ea62 Author: Xinchen Hui <laruence@gmail.com> Fri, 20 Nov 2015 16:38:00 +0800 Committer: Anatol Belski <ab@php.net> Thu, 19 Nov 2015 19:25:05 +0100 Parents: 01b88f87ba3638297f0f9afb2352c3acdeb18e42 Branches: PHP-7.0.0 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=cbb3f7f15ac95ec173498391382910f82622ea62 Log: Merge branch 'PHP-5.6' into PHP-7..0 Conflicts: Zend/zend_exceptions.c Changed paths: A Zend/tests/bug70944.phpt M Zend/zend_exceptions.c Diff: diff --git a/Zend/tests/bug70944.phpt b/Zend/tests/bug70944.phpt new file mode 100644 index 0000000..f14af65 --- /dev/null +++ b/Zend/tests/bug70944.phpt @@ -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 diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 002f519..dd137df 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -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 {

« previous php.cvs (#89936) next »