com php-src: Port the fix of 5.6 to 7.0: Zend/tests/bug70944.phpt Zend/zend_exceptions.c
| From: | Xinchen Hui | Date: | Sat, 21 Nov 2015 13:41:53 +0000 |
| Subject: | com php-src: Port the fix of 5.6 to 7.0: Zend/tests/bug70944.phpt Zend/zend_exceptions.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-89949@lists.php.net to get a copy of this message | ||
Commit: 31d93fcf4bb7efdbc6340692011a8b293eab07b8
Author: Xinchen Hui <laruence@gmail.com> Sat, 21 Nov 2015 05:16:11 -0800
Parents: c6961cb41bebf1322b75af41f68c26fb875c51d9
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=31d93fcf4bb7efdbc6340692011a8b293eab07b8
Log:
Port the fix of 5.6 to 7.0
Changed paths:
M Zend/tests/bug70944.phpt
M Zend/zend_exceptions.c
Diff:
diff --git a/Zend/tests/bug70944.phpt b/Zend/tests/bug70944.phpt
index 192fd6d..afb10bc 100644
--- a/Zend/tests/bug70944.phpt
+++ b/Zend/tests/bug70944.phpt
@@ -25,13 +25,13 @@ try {
}
?>
--EXPECTF--
-string(%d) "exception 'Exception' with message 'Foo' in %sbug70944.php:%d
+string(%d) "Exception: Foo in %sbug70944.php:%d
Stack trace:
#0 {main}"
-string(%d) "exception 'Exception' with message 'Foo' in %sbug70944.php:%d
+string(%d) "Exception: Foo in %sbug70944.php:%d
Stack trace:
#0 {main}
-Next exception 'Exception' with message 'Dummy' in %sbug70944.php:%d
+Next Exception: Dummy in %sbug70944.php:%d
Stack trace:
#0 {main}"
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index dd137df..147fbe8 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -70,37 +70,38 @@ ZEND_API zend_class_entry *zend_get_exception_base(zval *object)
void zend_exception_set_previous(zend_object *exception, zend_object *add_previous)
{
- zval *previous, *pzv;
- zval tmp, zv, rv;
+ zval *previous, *ancestor, *ex;
+ zval pv, zv, rv;
zend_class_entry *base_ce;
if (exception == add_previous || !add_previous || !exception) {
return;
}
- ZVAL_OBJ(&tmp, add_previous);
- if (!instanceof_function(Z_OBJCE(tmp), zend_ce_throwable)) {
+ ZVAL_OBJ(&pv, add_previous);
+ if (!instanceof_function(Z_OBJCE(pv), zend_ce_throwable)) {
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;
+ ex = &zv;
do {
- base_ce = i_get_exception_base(pzv);
- previous = zend_read_property(base_ce, pzv, "previous", sizeof("previous")-1,
1, &rv);
+ ancestor = zend_read_property(i_get_exception_base(&pv), &pv, "previous",
sizeof("previous")-1, 1, &rv);
+ while (Z_TYPE_P(ancestor) == IS_OBJECT) {
+ if (Z_OBJ_P(ancestor) == Z_OBJ_P(ex)) {
+ OBJ_RELEASE(add_previous);
+ return;
+ }
+ ancestor = zend_read_property(i_get_exception_base(ancestor), ancestor, "previous",
sizeof("previous")-1, 1, &rv);
+ }
+ base_ce = i_get_exception_base(ex);
+ previous = zend_read_property(base_ce, ex, "previous", sizeof("previous")-1,
1, &rv);
if (Z_TYPE_P(previous) == IS_NULL) {
- zend_update_property(base_ce, pzv, "previous", sizeof("previous")-1,
&tmp);
+ zend_update_property(base_ce, ex, "previous", sizeof("previous")-1,
&pv);
GC_REFCOUNT(add_previous)--;
return;
}
- pzv = previous;
- } while (pzv && Z_OBJ_P(pzv) != add_previous);
+ ex = previous;
+ } while (Z_OBJ_P(ex) != add_previous);
}
void zend_exception_save(void) /* {{{ */