diff options
author | Xinchen Hui <laruence@gmail.com> | 2017-05-31 12:39:26 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@gmail.com> | 2017-05-31 12:39:26 +0800 |
commit | 9c5717d0decd56710129a5599fe5d38f82a7bab2 (patch) | |
tree | 9e6cdf8f2bf49137ee54d09167f930d9525e30aa /ext/reflection/php_reflection.c | |
parent | 77cbf8a6578c8de42a236337ee1d3071a6178f5e (diff) | |
download | php-git-9c5717d0decd56710129a5599fe5d38f82a7bab2.tar.gz |
Fixed bug #74673 (Segfault when cast Reflection object to string with undefined constant)
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r-- | ext/reflection/php_reflection.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 7d703262f1..5b162f759e 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -462,7 +462,9 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in zval *value; ZEND_HASH_FOREACH_STR_KEY_VAL(&ce->constants_table, key, value) { - zval_update_constant_ex(value, 1, NULL); + if (UNEXPECTED(zval_update_constant_ex(value, 1, NULL) == FAILURE)) { + return; + } _const_string(str, ZSTR_VAL(key), value, indent); } ZEND_HASH_FOREACH_END(); } @@ -708,7 +710,11 @@ static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg ZVAL_DUP(&zv, RT_CONSTANT(&fptr->op_array, precv->op2)); old_scope = EG(scope); EG(scope) = fptr->common.scope; - zval_update_constant_ex(&zv, 1, NULL); + if (UNEXPECTED(zval_update_constant_ex(&zv, 1, NULL) == FAILURE)) { + EG(scope) = old_scope; + zval_ptr_dtor(&zv); + return; + } EG(scope) = old_scope; if (Z_TYPE(zv) == IS_TRUE) { string_write(str, "true", sizeof("true")-1); |