Skip to content

Commit 47d8218

Browse files
committed
zend: find_frameless_function_offset() walking past the handler array's end.
The loop tested the cursor pointer, not the slot, so it never stopped on the NULL terminator. It now counts off zend_flf_count, and the caller advances instead of spinning on continue.
1 parent f142b81 commit 47d8218

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

Zend/zend_compile.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4925,15 +4925,14 @@ static zend_result zend_compile_func_array_slice(znode *result, const zend_ast_l
49254925

49264926
static uint32_t find_frameless_function_offset(uint32_t arity, const void *handler)
49274927
{
4928-
void **handlers = zend_flf_handlers;
4929-
void **current = handlers;
4930-
while (current) {
4931-
if (*current == handler) {
4932-
return current - handlers;
4928+
for (size_t i = 0; i < zend_flf_count; i++) {
4929+
if (zend_flf_handlers[i] == handler) {
4930+
return (uint32_t)i;
49334931
}
4934-
current++;
49354932
}
49364933

4934+
/* Unreachable in practice: zend_register_functions() records the handler
4935+
* of every frameless_function_infos entry at registration time. */
49374936
return (uint32_t)-1;
49384937
}
49394938

@@ -4963,10 +4962,9 @@ static const zend_frameless_function_info *find_frameless_function_info(const ze
49634962
|| frameless_function_info->num_args == args->children)) {
49644963
uint32_t num_args = frameless_function_info->num_args;
49654964
uint32_t offset = find_frameless_function_offset(num_args, frameless_function_info->handler);
4966-
if (offset == (uint32_t)-1) {
4967-
continue;
4965+
if (offset != (uint32_t)-1) {
4966+
return frameless_function_info;
49684967
}
4969-
return frameless_function_info;
49704968
}
49714969
frameless_function_info++;
49724970
}

0 commit comments

Comments
 (0)