]> granicus.if.org Git - php/commitdiff
Check for name vs ce in a few more places
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 14 Jul 2020 12:44:35 +0000 (14:44 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 14 Jul 2020 12:47:47 +0000 (14:47 +0200)
The type lists may contain CEs, we should not assume they only
contain names.

ext/opcache/zend_persist.c
ext/opcache/zend_persist_calc.c

index e6b5194bfeb1029d9000fa92bdd67e3c1070d64a..b37504c4b0606974447dbe42db642c7a7a4c95cf 100644 (file)
@@ -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)
index a7b347ee0ee2e3621df0e90fd9716f3ead5e9313..e184b03e77def78ff721c7fbc78c102802039d1d 100644 (file)
@@ -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)