Skip to content

Commit 7e6b2e2

Browse files
committed
Check for name vs ce in a few more places
The type lists may contain CEs, we should not assume they only contain names.
1 parent 7c16d11 commit 7e6b2e2

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

ext/opcache/zend_persist.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ static HashTable *zend_persist_attributes(HashTable *attributes)
294294

295295
static void zend_persist_type(zend_type *type) {
296296
if (ZEND_TYPE_HAS_LIST(*type)) {
297-
zend_type *list_type;
298297
zend_type_list *list = ZEND_TYPE_LIST(*type);
299298
if (ZEND_TYPE_USES_ARENA(*type)) {
300299
if (!ZCG(is_immutable_class)) {
@@ -308,17 +307,16 @@ static void zend_persist_type(zend_type *type) {
308307
list = zend_shared_memdup_put_free(list, ZEND_TYPE_LIST_SIZE(list->num_types));
309308
}
310309
ZEND_TYPE_SET_PTR(*type, list);
310+
}
311311

312-
ZEND_TYPE_LIST_FOREACH(list, list_type) {
313-
zend_string *type_name = ZEND_TYPE_NAME(*list_type);
312+
zend_type *single_type;
313+
ZEND_TYPE_FOREACH(*type, single_type) {
314+
if (ZEND_TYPE_HAS_NAME(*single_type)) {
315+
zend_string *type_name = ZEND_TYPE_NAME(*single_type);
314316
zend_accel_store_interned_string(type_name);
315-
ZEND_TYPE_SET_PTR(*list_type, type_name);
316-
} ZEND_TYPE_LIST_FOREACH_END();
317-
} else if (ZEND_TYPE_HAS_NAME(*type)) {
318-
zend_string *type_name = ZEND_TYPE_NAME(*type);
319-
zend_accel_store_interned_string(type_name);
320-
ZEND_TYPE_SET_PTR(*type, type_name);
321-
}
317+
ZEND_TYPE_SET_PTR(*single_type, type_name);
318+
}
319+
} ZEND_TYPE_FOREACH_END();
322320
}
323321

324322
static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_script* main_persistent_script)

ext/opcache/zend_persist_calc.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,22 +174,21 @@ static void zend_persist_attributes_calc(HashTable *attributes)
174174
static void zend_persist_type_calc(zend_type *type)
175175
{
176176
if (ZEND_TYPE_HAS_LIST(*type)) {
177-
zend_type *list_type;
178177
if (ZEND_TYPE_USES_ARENA(*type) && !ZCG(is_immutable_class)) {
179178
ADD_ARENA_SIZE(ZEND_TYPE_LIST_SIZE(ZEND_TYPE_LIST(*type)->num_types));
180179
} else {
181180
ADD_SIZE(ZEND_TYPE_LIST_SIZE(ZEND_TYPE_LIST(*type)->num_types));
182181
}
183-
ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(*type), list_type) {
184-
zend_string *type_name = ZEND_TYPE_NAME(*list_type);
185-
ADD_INTERNED_STRING(type_name);
186-
ZEND_TYPE_SET_PTR(*list_type, type_name);
187-
} ZEND_TYPE_LIST_FOREACH_END();
188-
} else if (ZEND_TYPE_HAS_NAME(*type)) {
189-
zend_string *type_name = ZEND_TYPE_NAME(*type);
190-
ADD_INTERNED_STRING(type_name);
191-
ZEND_TYPE_SET_PTR(*type, type_name);
192182
}
183+
184+
zend_type *single_type;
185+
ZEND_TYPE_FOREACH(*type, single_type) {
186+
if (ZEND_TYPE_HAS_NAME(*single_type)) {
187+
zend_string *type_name = ZEND_TYPE_NAME(*single_type);
188+
ADD_INTERNED_STRING(type_name);
189+
ZEND_TYPE_SET_PTR(*single_type, type_name);
190+
}
191+
} ZEND_TYPE_FOREACH_END();
193192
}
194193

195194
static void zend_persist_op_array_calc_ex(zend_op_array *op_array)

0 commit comments

Comments
 (0)