summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2017-05-31 13:08:26 +0800
committerXinchen Hui <laruence@gmail.com>2017-05-31 13:08:26 +0800
commit9064dca58ba87ccdbf6cee71122e50595765cfa1 (patch)
tree32606c4f50526ec7b531ac0119076225cc61dc7b /ext
parent316aaca15503f8e40a6c578c0f90d122e393d283 (diff)
parent9c5717d0decd56710129a5599fe5d38f82a7bab2 (diff)
downloadphp-git-9064dca58ba87ccdbf6cee71122e50595765cfa1.tar.gz
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: Fixed bug #74673 (Segfault when cast Reflection object to string with undefined constant) Conflicts: ext/reflection/php_reflection.c
Diffstat (limited to 'ext')
-rw-r--r--ext/reflection/php_reflection.c8
-rw-r--r--ext/reflection/tests/bug74673.phpt22
2 files changed, 29 insertions, 1 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index a06522d025..db7056e03b 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -468,6 +468,9 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->constants_table, key, c) {
_class_const_string(str, ZSTR_VAL(key), c, ZSTR_VAL(sub_indent.buf));
+ if (UNEXPECTED(EG(exception))) {
+ return;
+ }
} ZEND_HASH_FOREACH_END();
}
string_printf(str, "%s }\n", indent);
@@ -732,7 +735,10 @@ static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg
string_write(str, " = ", sizeof(" = ")-1);
ZVAL_DUP(&zv, RT_CONSTANT(&fptr->op_array, precv->op2));
- zval_update_constant_ex(&zv, fptr->common.scope);
+ if (UNEXPECTED(zval_update_constant_ex(&zv, fptr->common.scope) == FAILURE)) {
+ zval_ptr_dtor(&zv);
+ return;
+ }
if (Z_TYPE(zv) == IS_TRUE) {
string_write(str, "true", sizeof("true")-1);
} else if (Z_TYPE(zv) == IS_FALSE) {
diff --git a/ext/reflection/tests/bug74673.phpt b/ext/reflection/tests/bug74673.phpt
new file mode 100644
index 0000000000..8e4e8e3a18
--- /dev/null
+++ b/ext/reflection/tests/bug74673.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #74673 (Segfault when cast Reflection object to string with undefined constant)
+--FILE--
+<?php
+
+set_error_handler(function() {
+ throw new Exception();
+});
+
+class A
+{
+ public function method($test = PHP_SELF + 1)
+ {
+ }
+}
+
+$class = new ReflectionClass('A');
+
+echo $class;
+?>
+--EXPECTF--
+Fatal error: Method ReflectionClass::__toString() must not throw an exception, caught Exception: in %sbug74673.php on line %d