[php-src] master: Zend: fix find_frameless_function_offset() walking past the handler array
| From: | David Carlier | Date: | Sun, 18 Oct 2026 11:13:36 +0000 |
| Subject: | [php-src] master: Zend: fix find_frameless_function_offset() walking past the handler array | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-142397@lists.php.net to get a copy of this message | ||
Author: David Carlier (devnexen)
Date: 2026-10-18T12:13:02+01:00
Commit: https://github.com/php/php-src/commit/758abd57d38afe3048bb6e9563cbe37594961d6b
Raw diff: https://github.com/php/php-src/commit/758abd57d38afe3048bb6e9563cbe37594961d6b.diff
Zend: fix find_frameless_function_offset() walking past the handler array
The loop tested the cursor pointer, not the slot, so it never stopped on the
NULL terminator. It now checks the slot, and the caller advances instead of
spinning on continue.
Close GH-23516
Changed paths:
M Zend/zend_compile.c
Diff:
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index ffd40f06014d..f33ae242fee1 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -4916,13 +4916,15 @@ static uint32_t find_frameless_function_offset(uint32_t arity, const void
*handl
{
void **handlers = zend_flf_handlers;
void **current = handlers;
- while (current) {
+ while (*current) {
if (*current == handler) {
return current - handlers;
}
current++;
}
+ /* Unreachable in practice: zend_register_functions() records the handler
+ * of every frameless_function_infos entry at registration time. */
return (uint32_t)-1;
}
@@ -4952,10 +4954,9 @@ static const zend_frameless_function_info *find_frameless_function_info(const
ze
|| frameless_function_info->num_args == args->children)) {
uint32_t num_args = frameless_function_info->num_args;
uint32_t offset = find_frameless_function_offset(num_args, frameless_function_info->handler);
- if (offset == (uint32_t)-1) {
- continue;
+ if (offset != (uint32_t)-1) {
+ return frameless_function_info;
}
- return frameless_function_info;
}
frameless_function_info++;
}