Skip to content

Commit 782af7a

Browse files
committed
Fix -Walloc-size warning
It's indeed unsafe to treat zend_internal_function as zend_function, because sizeof(zend_internal_function) < sizeof(zend_function), which can lead to buffer overflows. This might also be UB. Either way, this would need to be addressed in the whole codebase.
1 parent 529a71f commit 782af7a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Zend/zend_inheritance.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static zend_function *zend_duplicate_internal_function(zend_function *func, zend
9797
zend_function *new_function;
9898

9999
if (UNEXPECTED(ce->type & ZEND_INTERNAL_CLASS)) {
100-
new_function = pemalloc(sizeof(zend_internal_function), 1);
100+
new_function = (zend_function *)pemalloc(sizeof(zend_internal_function), 1);
101101
memcpy(new_function, func, sizeof(zend_internal_function));
102102
} else {
103103
new_function = zend_arena_alloc(&CG(arena), sizeof(zend_internal_function));

0 commit comments

Comments
 (0)