Commit 0b4a5a84492 for php
commit 0b4a5a8449261fd225abf0cca97323fbd459777c
Author: Marc Bennewitz <marc-mabe@users.noreply.github.com>
Date: Thu Oct 15 21:00:12 2026 +0200
Fix GCC 15 -Walloc-size warnings in ext/ffi (#24344)
The trampoline fallbacks in zend_ffi_cdata_get_closure() and
zend_ffi_get_func() deliberately allocate only a zend_internal_function
but assign it to a zend_function pointer. GCC 15 reports this as
"allocation of insufficient size", which breaks --enable-werror builds.
Use the same uintptr_t cast as zend_get_property_hook_trampoline().
diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c
index 0f6e7626d83..3a3ef149a3f 100644
--- a/ext/ffi/ffi.c
+++ b/ext/ffi/ffi.c
@@ -2163,7 +2163,7 @@ static zend_result zend_ffi_cdata_get_closure(zend_object *obj, zend_class_entry
if (EXPECTED(EG(trampoline).common.function_name == NULL)) {
func = &EG(trampoline);
} else {
- func = ecalloc(1, sizeof(zend_internal_function));
+ func = (zend_function *)(uintptr_t)ecalloc(1, sizeof(zend_internal_function));
}
func->type = ZEND_INTERNAL_FUNCTION;
func->common.arg_flags[0] = 0;
@@ -2943,7 +2943,7 @@ static zend_function *zend_ffi_get_func(zend_object **obj, zend_string *name, co
if (EXPECTED(EG(trampoline).common.function_name == NULL)) {
func = &EG(trampoline);
} else {
- func = ecalloc(1, sizeof(zend_internal_function));
+ func = (zend_function *)(uintptr_t)ecalloc(1, sizeof(zend_internal_function));
}
func->common.type = ZEND_INTERNAL_FUNCTION;
func->common.arg_flags[0] = 0;