diff options
| author | Xinchen Hui <laruence@gmail.com> | 2015-11-20 16:24:53 +0800 |
|---|---|---|
| committer | Xinchen Hui <laruence@gmail.com> | 2015-11-20 16:24:53 +0800 |
| commit | a1c887964e34c0531b238e33a6b85e9925731194 (patch) | |
| tree | 25c180334f4d6117d7412f481696636884e57376 /Zend/zend_exceptions.c | |
| parent | b42eb16cf4ae58e8c8fbc8afc4406bc746497754 (diff) | |
| download | php-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.c | 9 |
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) { |
