]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.0' into PHP-7.1
authorXinchen Hui <laruence@gmail.com>
Wed, 31 May 2017 05:08:26 +0000 (13:08 +0800)
committerXinchen Hui <laruence@gmail.com>
Wed, 31 May 2017 05:08:26 +0000 (13:08 +0800)
* PHP-7.0:
  Fixed bug #74673 (Segfault when cast Reflection object to string with undefined constant)

Conflicts:
ext/reflection/php_reflection.c

1  2 
ext/reflection/php_reflection.c

index a06522d025b0af3e6ba10a0f6964086b7e6f5458,5b162f759ed700573e0cb3095c8f89a70970748a..db7056e03b7071d15858224c1c6c472ec58ef401
@@@ -464,10 -459,13 +464,13 @@@ static void _class_string(string *str, 
        string_printf(str, "%s  - Constants [%d] {\n", indent, count);
        if (count > 0) {
                zend_string *key;
 -              zval *value;
 +              zend_class_constant *c;
  
 -              ZEND_HASH_FOREACH_STR_KEY_VAL(&ce->constants_table, key, value) {
 -                      if (UNEXPECTED(zval_update_constant_ex(value, 1, NULL) == FAILURE)) {
 +              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;
+                       }
 -                      _const_string(str, ZSTR_VAL(key), value, indent);
                } ZEND_HASH_FOREACH_END();
        }
        string_printf(str, "%s  }\n", indent);
@@@ -732,7 -707,15 +735,10 @@@ static void _parameter_string(string *s
  
                        string_write(str, " = ", sizeof(" = ")-1);
                        ZVAL_DUP(&zv, RT_CONSTANT(&fptr->op_array, precv->op2));
-                       zval_update_constant_ex(&zv, fptr->common.scope);
 -                      old_scope = EG(scope);
 -                      EG(scope) = fptr->common.scope;
 -                      if (UNEXPECTED(zval_update_constant_ex(&zv, 1, NULL) == FAILURE)) {
 -                              EG(scope) = old_scope;
++                      if (UNEXPECTED(zval_update_constant_ex(&zv, fptr->common.scope) == FAILURE)) {
+                               zval_ptr_dtor(&zv);
+                               return;
+                       }
 -                      EG(scope) = old_scope;
                        if (Z_TYPE(zv) == IS_TRUE) {
                                string_write(str, "true", sizeof("true")-1);
                        } else if (Z_TYPE(zv) == IS_FALSE) {