Repository navigation
zend: find_frameless_function_offset() walking past the handler array… #23516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4927,13 +4927,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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment is good |
||
| * of every frameless_function_infos entry at registration time. */ | ||
| return (uint32_t)-1; | ||
| } | ||
|
|
||
|
|
@@ -4963,10 +4965,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) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this cleanup or necessary?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| continue; | ||
| if (offset != (uint32_t)-1) { | ||
| return frameless_function_info; | ||
| } | ||
| return frameless_function_info; | ||
| } | ||
| frameless_function_info++; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
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)