Closed as not planned
Closed as not planned
Description
Description
When doing
function str_starts_with(string $haystack, string ...$needle): bool {}
(...)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_str_starts_with, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, haystack, IS_STRING, 0)
ZEND_ARG_VARIADIC_TYPE_INFO(0, needle, IS_STRING, 0)
ZEND_END_ARG_INFO()
You would think that the string type would be enforced with strict_types=1
but it doesn't! If you do
function str_starts_with(string $haystack, string ...$needle): bool {}
(...)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_str_starts_with, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, haystack, IS_STRING, 0)
ZEND_ARG_VARIADIC_TYPE_INFO(0, needle, IS_STRING, 0)
ZEND_END_ARG_INFO()
(...)
zval *needles;
size_t num_needles;
ZEND_PARSE_PARAMETERS_START(2, -1)
Z_PARAM_STR(haystack)
Z_PARAM_VARIADIC('+', needles, num_needles)
ZEND_PARSE_PARAMETERS_END();
for (size_t i = 0; i < num_needles; ++i) {
Z_STR(needles[i]); // << segfault on int
}
and 1 of the needles is an int, you get a segfault!
PHP Version
current git master, 3399235bec275516f6b87714087526d36d6f6976
Operating System
Ubuntu 24.04