[php-src] master: [`%pS` migration] Use `%pS` in ext/standard/string.c

From: Date: Sun, 01 Nov 2026 20:32:23 +0000
Subject: [php-src] master: [`%pS` migration] Use `%pS` in ext/standard/string.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143188@lists.php.net to get a copy of this message
Author: Daniel Scherzer (DanielEScherzer) Date: 2026-11-01T12:30:54-08:00 Commit: https://github.com/php/php-src/commit/9b622db7fcb3d557c79f6e29f8f3078c13835327 Raw diff: https://github.com/php/php-src/commit/9b622db7fcb3d557c79f6e29f8f3078c13835327.diff [%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(). Changed paths: M Zend/zend_API.c M ext/standard/string.c Diff: diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 221c6b89affa..6ca5430d392a 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 217a8fac95c2..b8735b70126a 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);

« previous php.cvs (#143188) next »