From: Nikita Popov Date: Tue, 14 Jul 2020 12:44:35 +0000 (+0200) Subject: Check for name vs ce in a few more places X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e6b2e2e2324b7a2bba3da1ad3ae4837a1052262;p=php Check for name vs ce in a few more places The type lists may contain CEs, we should not assume they only contain names. --- diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index e6b5194bfe..b37504c4b0 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -294,7 +294,6 @@ static HashTable *zend_persist_attributes(HashTable *attributes) static void zend_persist_type(zend_type *type) { if (ZEND_TYPE_HAS_LIST(*type)) { - zend_type *list_type; zend_type_list *list = ZEND_TYPE_LIST(*type); if (ZEND_TYPE_USES_ARENA(*type)) { if (!ZCG(is_immutable_class)) { @@ -308,17 +307,16 @@ static void zend_persist_type(zend_type *type) { list = zend_shared_memdup_put_free(list, ZEND_TYPE_LIST_SIZE(list->num_types)); } ZEND_TYPE_SET_PTR(*type, list); + } - ZEND_TYPE_LIST_FOREACH(list, list_type) { - zend_string *type_name = ZEND_TYPE_NAME(*list_type); + zend_type *single_type; + ZEND_TYPE_FOREACH(*type, single_type) { + if (ZEND_TYPE_HAS_NAME(*single_type)) { + zend_string *type_name = ZEND_TYPE_NAME(*single_type); zend_accel_store_interned_string(type_name); - ZEND_TYPE_SET_PTR(*list_type, type_name); - } ZEND_TYPE_LIST_FOREACH_END(); - } else if (ZEND_TYPE_HAS_NAME(*type)) { - zend_string *type_name = ZEND_TYPE_NAME(*type); - zend_accel_store_interned_string(type_name); - ZEND_TYPE_SET_PTR(*type, type_name); - } + ZEND_TYPE_SET_PTR(*single_type, type_name); + } + } ZEND_TYPE_FOREACH_END(); } static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_script* main_persistent_script) diff --git a/ext/opcache/zend_persist_calc.c b/ext/opcache/zend_persist_calc.c index a7b347ee0e..e184b03e77 100644 --- a/ext/opcache/zend_persist_calc.c +++ b/ext/opcache/zend_persist_calc.c @@ -174,22 +174,21 @@ static void zend_persist_attributes_calc(HashTable *attributes) static void zend_persist_type_calc(zend_type *type) { if (ZEND_TYPE_HAS_LIST(*type)) { - zend_type *list_type; if (ZEND_TYPE_USES_ARENA(*type) && !ZCG(is_immutable_class)) { ADD_ARENA_SIZE(ZEND_TYPE_LIST_SIZE(ZEND_TYPE_LIST(*type)->num_types)); } else { ADD_SIZE(ZEND_TYPE_LIST_SIZE(ZEND_TYPE_LIST(*type)->num_types)); } - ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(*type), list_type) { - zend_string *type_name = ZEND_TYPE_NAME(*list_type); - ADD_INTERNED_STRING(type_name); - ZEND_TYPE_SET_PTR(*list_type, type_name); - } ZEND_TYPE_LIST_FOREACH_END(); - } else if (ZEND_TYPE_HAS_NAME(*type)) { - zend_string *type_name = ZEND_TYPE_NAME(*type); - ADD_INTERNED_STRING(type_name); - ZEND_TYPE_SET_PTR(*type, type_name); } + + zend_type *single_type; + ZEND_TYPE_FOREACH(*type, single_type) { + if (ZEND_TYPE_HAS_NAME(*single_type)) { + zend_string *type_name = ZEND_TYPE_NAME(*single_type); + ADD_INTERNED_STRING(type_name); + ZEND_TYPE_SET_PTR(*single_type, type_name); + } + } ZEND_TYPE_FOREACH_END(); } static void zend_persist_op_array_calc_ex(zend_op_array *op_array)