Skip to content

Commit e84faa9

Browse files
committed
Fix handling of empty named arg
1 parent 1132a8b commit e84faa9

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

Zend/zend_execute.c

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5395,31 +5395,29 @@ static zend_always_inline uint32_t zend_get_arg_offset_by_name(
53955395
return *(uintptr_t *)(cache_slot + 1);
53965396
}
53975397

5398-
if (UNEXPECTED(ZSTR_LEN(arg_name) == 0)) {
5399-
return (uint32_t)-1;
5400-
}
5401-
5402-
// TODO: Use a hash table?
5403-
uint32_t num_args = fbc->common.num_args;
5404-
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION)
5405-
|| EXPECTED(fbc->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) {
5406-
for (uint32_t i = 0; i < num_args; i++) {
5407-
zend_arg_info *arg_info = &fbc->op_array.arg_info[i];
5408-
if (zend_string_equals(arg_name, arg_info->name)) {
5409-
*cache_slot = fbc;
5410-
*(uintptr_t *)(cache_slot + 1) = i;
5411-
return i;
5398+
if (EXPECTED(ZSTR_LEN(arg_name) > 0)) {
5399+
// TODO: Use a hash table?
5400+
uint32_t num_args = fbc->common.num_args;
5401+
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION)
5402+
|| EXPECTED(fbc->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) {
5403+
for (uint32_t i = 0; i < num_args; i++) {
5404+
zend_arg_info *arg_info = &fbc->op_array.arg_info[i];
5405+
if (zend_string_equals(arg_name, arg_info->name)) {
5406+
*cache_slot = fbc;
5407+
*(uintptr_t *)(cache_slot + 1) = i;
5408+
return i;
5409+
}
54125410
}
5413-
}
5414-
} else {
5415-
ZEND_ASSERT(num_args == 0 || fbc->internal_function.arg_info);
5416-
for (uint32_t i = 0; i < num_args; i++) {
5417-
zend_internal_arg_info *arg_info = &fbc->internal_function.arg_info[i];
5418-
size_t len = strlen(arg_info->name);
5419-
if (zend_string_equals_cstr(arg_name, arg_info->name, len)) {
5420-
*cache_slot = fbc;
5421-
*(uintptr_t *)(cache_slot + 1) = i;
5422-
return i;
5411+
} else {
5412+
ZEND_ASSERT(num_args == 0 || fbc->internal_function.arg_info);
5413+
for (uint32_t i = 0; i < num_args; i++) {
5414+
zend_internal_arg_info *arg_info = &fbc->internal_function.arg_info[i];
5415+
size_t len = strlen(arg_info->name);
5416+
if (zend_string_equals_cstr(arg_name, arg_info->name, len)) {
5417+
*cache_slot = fbc;
5418+
*(uintptr_t *)(cache_slot + 1) = i;
5419+
return i;
5420+
}
54235421
}
54245422
}
54255423
}

0 commit comments

Comments
 (0)