Skip to content

Commit aef3bb7

Browse files
committed
Fix enum cast AST allocation, again
We always need to allocate space for the three children, and only don't need one of the zend_ast_zval structures.
1 parent c1959e6 commit aef3bb7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Zend/zend_enum.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,15 +417,14 @@ ZEND_API zend_class_entry *zend_register_internal_enum(
417417
static zend_ast_ref *create_enum_case_ast(
418418
zend_string *class_name, zend_string *case_name, zval *value) {
419419
// TODO: Use custom node type for enum cases?
420-
size_t num_children = value ? 3 : 2;
421-
size_t size = sizeof(zend_ast_ref) + zend_ast_size(num_children)
422-
+ num_children * sizeof(zend_ast_zval);
420+
size_t size = sizeof(zend_ast_ref) + zend_ast_size(3)
421+
+ (value ? 3 : 2) * sizeof(zend_ast_zval);
423422
char *p = pemalloc(size, 1);
424423
zend_ast_ref *ref = (zend_ast_ref *) p; p += sizeof(zend_ast_ref);
425424
GC_SET_REFCOUNT(ref, 1);
426425
GC_TYPE_INFO(ref) = GC_CONSTANT_AST | GC_PERSISTENT | GC_IMMUTABLE;
427426

428-
zend_ast *ast = (zend_ast *) p; p += zend_ast_size(num_children);
427+
zend_ast *ast = (zend_ast *) p; p += zend_ast_size(3);
429428
ast->kind = ZEND_AST_CONST_ENUM_INIT;
430429
ast->attr = 0;
431430
ast->lineno = 0;

0 commit comments

Comments
 (0)