1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

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.
This commit is contained in:
Ilija Tovilo
2024-04-29 16:36:24 +02:00
parent 529a71ff2e
commit 782af7a963

View File

@@ -97,7 +97,7 @@ static zend_function *zend_duplicate_internal_function(zend_function *func, zend
zend_function *new_function;
if (UNEXPECTED(ce->type & ZEND_INTERNAL_CLASS)) {
new_function = pemalloc(sizeof(zend_internal_function), 1);
new_function = (zend_function *)pemalloc(sizeof(zend_internal_function), 1);
memcpy(new_function, func, sizeof(zend_internal_function));
} else {
new_function = zend_arena_alloc(&CG(arena), sizeof(zend_internal_function));