Skip to content

Commit 7248014

Browse files
committed
Zend: fix zend_ast_size definition
It is better not to use sizeof(struct_with_flexible_array) and instead rely on offsetof(type, member) like most other similar wrappers do.
1 parent bb28de9 commit 7248014

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Zend/zend_ast.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ typedef void (*zend_ast_apply_func)(zend_ast **ast_ptr, void *context);
313313
ZEND_API void zend_ast_apply(zend_ast *ast, zend_ast_apply_func fn, void *context);
314314

315315
static zend_always_inline size_t zend_ast_size(uint32_t children) {
316-
return sizeof(zend_ast) - sizeof(zend_ast *) + sizeof(zend_ast *) * children;
316+
ZEND_ASSERT(children > 0);
317+
return XtOffsetOf(zend_ast, child) + (sizeof(zend_ast *) * children);
317318
}
318319

319320
static zend_always_inline bool zend_ast_is_special(zend_ast *ast) {

0 commit comments

Comments
 (0)