From 782af7a963e66b4da7646b4c84d820fa376d88b0 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 29 Apr 2024 16:36:24 +0200 Subject: [PATCH] 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. --- Zend/zend_inheritance.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 491d68714b3..c07415ce820 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -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));