From: Xinchen Hui Date: Wed, 31 May 2017 05:12:24 +0000 (+0800) Subject: Merge branch 'PHP-7.1' X-Git-Tag: php-7.2.0alpha1~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bfd35512bb795f0b4f83c1c857acca7e6e552f6f;p=php Merge branch 'PHP-7.1' * PHP-7.1: Update NEWS Fixed bug #74673 (Segfault when cast Reflection object to string with undefined constant) Conflicts: ext/reflection/php_reflection.c --- bfd35512bb795f0b4f83c1c857acca7e6e552f6f diff --cc ext/reflection/php_reflection.c index b8c984a8bf,db7056e03b..3e5af0dbb8 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@@ -379,10 -467,13 +379,13 @@@ static void _class_string(smart_str *st zend_class_constant *c; ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->constants_table, key, c) { - _class_const_string(str, ZSTR_VAL(key), c, ZSTR_VAL(sub_indent.buf)); + _class_const_string(str, ZSTR_VAL(key), c, ZSTR_VAL(sub_indent)); + if (UNEXPECTED(EG(exception))) { + return; + } } ZEND_HASH_FOREACH_END(); } - string_printf(str, "%s }\n", indent); + smart_str_append_printf(str, "%s }\n", indent); /* Static properties */ /* counting static properties */ @@@ -635,27 -733,30 +638,30 @@@ static void _parameter_string(smart_st if (precv && precv->opcode == ZEND_RECV_INIT && precv->op2_type != IS_UNUSED) { zval zv; - string_write(str, " = ", sizeof(" = ")-1); + smart_str_appends(str, " = "); 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); + smart_str_appends(str, "true"); } else if (Z_TYPE(zv) == IS_FALSE) { - string_write(str, "false", sizeof("false")-1); + smart_str_appends(str, "false"); } else if (Z_TYPE(zv) == IS_NULL) { - string_write(str, "NULL", sizeof("NULL")-1); + smart_str_appends(str, "NULL"); } else if (Z_TYPE(zv) == IS_STRING) { - string_write(str, "'", sizeof("'")-1); - string_write(str, Z_STRVAL(zv), MIN(Z_STRLEN(zv), 15)); + smart_str_appendc(str, '\''); + smart_str_appendl(str, Z_STRVAL(zv), MIN(Z_STRLEN(zv), 15)); if (Z_STRLEN(zv) > 15) { - string_write(str, "...", sizeof("...")-1); + smart_str_appends(str, "..."); } - string_write(str, "'", sizeof("'")-1); + smart_str_appendc(str, '\''); } else if (Z_TYPE(zv) == IS_ARRAY) { - string_write(str, "Array", sizeof("Array")-1); + smart_str_appends(str, "Array"); } else { zend_string *zv_str = zval_get_string(&zv); - string_write(str, ZSTR_VAL(zv_str), ZSTR_LEN(zv_str)); + smart_str_append(str, zv_str); zend_string_release(zv_str); } zval_ptr_dtor(&zv);