Commit 9b622db7fcb for php
commit 9b622db7fcb3d557c79f6e29f8f3078c13835327
Author: Daniel Scherzer <daniel.e.scherzer@gmail.com>
Date: Sat Aug 8 13:14:12 2026 -0700
[`%pS` migration] Use `%pS` in ext/standard/string.c
In addition to the fixes within the string.c file, support for error strings
with null bytes was added to `zend_argument_value_error()`.
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 221c6b89aff..6ca5430d392 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -388,7 +388,6 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_error_variadic(
{
zend_string *func_name;
const char *arg_name;
- char *message = NULL;
if (EG(exception)) {
return;
}
@@ -396,12 +395,12 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_error_variadic(
func_name = get_function_or_method_name(function);
arg_name = get_function_arg_name(function, arg_num);
- zend_vspprintf(&message, 0, format, va);
- zend_throw_error(error_ce, "%pS(): Argument #%d%s%s%s %s",
+ zend_string *message = zend_vstrpprintf(0, format, va);
+ zend_throw_error(error_ce, "%pS(): Argument #%d%s%s%s %pS",
func_name, arg_num,
arg_name ? " ($" : "", arg_name ? arg_name : "", arg_name ? ")" : "", message
);
- efree(message);
+ zend_string_release(message);
zend_string_release(func_name);
}
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 217a8fac95c..b8735b70126 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -1399,7 +1399,7 @@ PHP_FUNCTION(str_decrement)
RETURN_THROWS();
}
if (ZSTR_LEN(str) >= 1 && ZSTR_VAL(str)[0] == '0') {
- zend_argument_value_error(1, "\"%s\" is out of decrement range", ZSTR_VAL(str));
+ zend_argument_value_error(1, "\"%pS\" is out of decrement range", str);
RETURN_THROWS();
}
@@ -1426,7 +1426,7 @@ PHP_FUNCTION(str_decrement)
if (UNEXPECTED(carry || (ZSTR_VAL(decremented)[0] == '0' && ZSTR_LEN(decremented) > 1))) {
if (ZSTR_LEN(decremented) == 1) {
zend_string_efree(decremented);
- zend_argument_value_error(1, "\"%s\" is out of decrement range", ZSTR_VAL(str));
+ zend_argument_value_error(1, "\"%pS\" is out of decrement range", str);
RETURN_THROWS();
}
zend_string *tmp = zend_string_alloc(ZSTR_LEN(decremented) - 1, 0);