diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 162b145fcfa1a..24ed5e9b53862 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -54,6 +54,9 @@ PHP 8.2 INTERNALS UPGRADE NOTES * Registered zend_observer_fcall_init handlers are now also called for internal functions. * The pestrdup and pestrndup macros and zend_strndup function are now also infallible for persistent strings, so checking for NULL is no longer necessary. +* The CHECK_NULL_PATH and CHECK_ZVAL_NULL_PATH macros are now wrappers using + the new inline functions: bool zend_str_has_nul_byte(const zend_string *str) + and zend_char_has_nul_byte(const char *s, size_t known_length) ======================== 2. Build system changes diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 2970299836689..5821a5b5f35bb 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -823,8 +823,18 @@ END_EXTERN_C() #define CHECK_ZVAL_STRING(z) #endif -#define CHECK_ZVAL_NULL_PATH(p) (Z_STRLEN_P(p) != strlen(Z_STRVAL_P(p))) -#define CHECK_NULL_PATH(p, l) (strlen(p) != (size_t)(l)) +static zend_always_inline bool zend_str_has_nul_byte(const zend_string *str) +{ + return ZSTR_LEN(str) != strlen(ZSTR_VAL(str)); +} +static zend_always_inline bool zend_char_has_nul_byte(const char *s, size_t known_length) +{ + return known_length != strlen(s); +} + +/* Compatibility with PHP 8.1 and below */ +#define CHECK_ZVAL_NULL_PATH(p) zend_str_has_nul_byte(Z_STR_P(p)) +#define CHECK_NULL_PATH(p, l) zend_char_has_nul_byte(p, l) #define ZVAL_STRINGL(z, s, l) do { \ ZVAL_NEW_STR(z, zend_string_init(s, l, 0)); \