summaryrefslogtreecommitdiff
path: root/Zend/zend_exceptions.c
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2015-11-20 16:24:53 +0800
committerXinchen Hui <laruence@gmail.com>2015-11-20 16:24:53 +0800
commita1c887964e34c0531b238e33a6b85e9925731194 (patch)
tree25c180334f4d6117d7412f481696636884e57376 /Zend/zend_exceptions.c
parentb42eb16cf4ae58e8c8fbc8afc4406bc746497754 (diff)
downloadphp-git-a1c887964e34c0531b238e33a6b85e9925731194.tar.gz
Fixed bug #70944 (try{ } finally{} can create infinite chains of exceptions)
Diffstat (limited to 'Zend/zend_exceptions.c')
-rw-r--r--Zend/zend_exceptions.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index 40248f7f5e..d1aa6fe9f1 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -36,7 +36,7 @@ ZEND_API void (*zend_throw_exception_hook)(zval *ex TSRMLS_DC);
void zend_exception_set_previous(zval *exception, zval *add_previous TSRMLS_DC)
{
- zval *previous;
+ zval *previous, *ancestor;
if (exception == add_previous || !add_previous || !exception) {
return;
@@ -45,6 +45,13 @@ void zend_exception_set_previous(zval *exception, zval *add_previous TSRMLS_DC)
zend_error(E_ERROR, "Cannot set non exception as previous exception");
return;
}
+ ancestor = zend_read_property(default_exception_ce, add_previous, "previous", sizeof("previous")-1, 1 TSRMLS_CC);
+ while (Z_TYPE_P(ancestor) == IS_OBJECT) {
+ if (Z_OBJ_HANDLE_P(ancestor) == Z_OBJ_HANDLE_P(exception)) {
+ return;
+ }
+ ancestor = zend_read_property(default_exception_ce, ancestor, "previous", sizeof("previous")-1, 1 TSRMLS_CC);
+ }
while (exception && exception != add_previous && Z_OBJ_HANDLE_P(exception) != Z_OBJ_HANDLE_P(add_previous)) {
previous = zend_read_property(default_exception_ce, exception, "previous", sizeof("previous")-1, 1 TSRMLS_CC);
if (Z_TYPE_P(previous) == IS_NULL) {