Skip to content

Commit cb3adf3

Browse files
committed
Fix OpCache build after 0b0259a
The intersection type needs to be marked as being allocated on the arena otherwise zend_persist_type() tries to free it and corrupts the Zend MM Heap Also we only need to allocate the space for a list of size 1 and not the whole length of the intersection type
1 parent 797ee86 commit cb3adf3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Zend/zend_compile.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -6522,23 +6522,25 @@ static zend_type zend_compile_typename(
65226522

65236523
ZEND_ASSERT(list->children == type_list->num_types);
65246524

6525-
ZEND_TYPE_FULL_MASK(type) |= _ZEND_TYPE_ARENA_BIT;
65266525
/* An implicitly nullable intersection type needs to be converted to a DNF type */
65276526
if (force_allow_null) {
65286527
zend_type intersection_type = ZEND_TYPE_INIT_NONE(0);
65296528
ZEND_TYPE_SET_LIST(intersection_type, type_list);
65306529
ZEND_TYPE_FULL_MASK(intersection_type) |= _ZEND_TYPE_INTERSECTION_BIT;
6530+
ZEND_TYPE_FULL_MASK(intersection_type) |= _ZEND_TYPE_ARENA_BIT;
65316531

6532-
zend_type_list *dnf_type_list = zend_arena_alloc(&CG(arena), ZEND_TYPE_LIST_SIZE(list->children));
6532+
zend_type_list *dnf_type_list = zend_arena_alloc(&CG(arena), ZEND_TYPE_LIST_SIZE(1));
65336533
dnf_type_list->num_types = 1;
65346534
dnf_type_list->types[0] = intersection_type;
65356535
ZEND_TYPE_SET_LIST(type, dnf_type_list);
65366536
/* Inform that the type list is a DNF type */
65376537
ZEND_TYPE_FULL_MASK(type) |= _ZEND_TYPE_UNION_BIT;
6538+
ZEND_TYPE_FULL_MASK(type) |= _ZEND_TYPE_ARENA_BIT;
65386539
} else {
65396540
ZEND_TYPE_SET_LIST(type, type_list);
65406541
/* Inform that the type list is an intersection type */
65416542
ZEND_TYPE_FULL_MASK(type) |= _ZEND_TYPE_INTERSECTION_BIT;
6543+
ZEND_TYPE_FULL_MASK(type) |= _ZEND_TYPE_ARENA_BIT;
65426544
}
65436545
} else {
65446546
type = zend_compile_single_typename(ast);

0 commit comments

Comments
 (0)