Skip to content

zend: find_frameless_function_offset() walking past the handler array… - #23516

Closed
devnexen wants to merge 2 commits into
php:masterfrom
devnexen:find_frameless_chg
Closed

devnexen wants to merge 2 commits into
php:masterfrom
devnexen:find_frameless_chg

Conversation

@devnexen

Copy link
Copy Markdown
Member

…'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.

…'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.
@devnexen
devnexen marked this pull request as ready for review August 30, 2026 20:52
Comment thread Zend/zend_compile.c
{
void **handlers = zend_flf_handlers;
void **current = handlers;
while (current) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why not change this to *current ? Seems nicer than rewriting the code (which would avoid an induction loop variable)

Comment thread Zend/zend_compile.c
|| 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) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this cleanup or necessary?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kind of is yes, frameless_function_info increment sits at the bottom of the while part, previously continue skipped it, before vs now: -1 as return could not happen, with *current it now can.

Comment thread Zend/zend_compile.c
current++;
}

/* Unreachable in practice: zend_register_functions() records the handler

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is good

@devnexen devnexen closed this in 758abd5 Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants