Add sanitity checks regarding num_args and arg_info (GH-16538)

`num_args > 0` implies that `arg_info != NULL`.  We explicitly assert
that during compilation and execution to make it easier for developers
to not miss this[1].

[1] <https://github.com/php/php-src/issues/16266>
This commit is contained in:
Christoph M. Becker 2024-10-25 15:52:53 +02:00 committed by GitHub
parent c40e6be82b
commit 91e6f2621c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 0 deletions

View File

@ -3709,6 +3709,7 @@ static uint32_t zend_get_arg_num(zend_function *fn, zend_string *arg_name) {
}
}
} else {
ZEND_ASSERT(fn->common.num_args == 0 || fn->internal_function.arg_info);
for (uint32_t i = 0; i < fn->common.num_args; i++) {
zend_internal_arg_info *arg_info = &fn->internal_function.arg_info[i];
size_t len = strlen(arg_info->name);

View File

@ -5304,6 +5304,7 @@ static zend_always_inline uint32_t zend_get_arg_offset_by_name(
}
}
} else {
ZEND_ASSERT(num_args == 0 || fbc->internal_function.arg_info);
for (uint32_t i = 0; i < num_args; i++) {
zend_internal_arg_info *arg_info = &fbc->internal_function.arg_info[i];
size_t len = strlen(arg_info->name);