From c4183fba003a8601fcdf4d9530fa2f38e3e0c100 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Tue, 8 Jul 2025 20:29:17 +0200 Subject: [PATCH 1/6] Fix GH-19070: setlocale($type, NULL) should not be deprecated This restores the old behaviour. Closes GH-19071. --- NEWS | 2 ++ ext/standard/basic_functions.stub.php | 4 ++-- ext/standard/basic_functions_arginfo.h | 2 +- ext/standard/string.c | 24 ++++++++++++-------- ext/standard/tests/strings/gh18823_weak.phpt | 3 +-- ext/standard/tests/strings/gh19070.phpt | 8 +++++++ 6 files changed, 28 insertions(+), 15 deletions(-) create mode 100644 ext/standard/tests/strings/gh19070.phpt diff --git a/NEWS b/NEWS index 7286bfccd50b0..39f85a9f7a6b5 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,8 @@ PHP NEWS - Standard: . Optimized pack(). (nielsdos, divinity76) + . Fixed bug GH-19070 (setlocale($type, NULL) should not be deprecated). + (nielsdos) - URI: . Return the singleton UrlValidationErrorType instances from Uri\WhatWg\Url diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index 740d3014f26a7..b7be370bb4777 100644 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -2555,8 +2555,8 @@ function nl2br(string $string, bool $use_xhtml = true): string {} function strip_tags(string $string, array|string|null $allowed_tags = null): string {} /** - * @param array|string $locales - * @param string $rest + * @param array|string|null $locales + * @param string|null $rest */ function setlocale(int $category, $locales, ...$rest): string|false {} diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index 8655941fe4ce7..c49e229cd6c0b 100644 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: f8c3745d39ed21f29f46b47f15b6fd1178e55dbb */ + * Stub hash: b9958c8f2f643e072ba7c6ee33ad238ea8dd702e */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0) diff --git a/ext/standard/string.c b/ext/standard/string.c index 75be1f1dcab1c..4bc56f550fe1b 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -4937,17 +4937,18 @@ PHP_FUNCTION(setlocale) zend_string **strings = do_alloca(sizeof(zend_string *) * num_args, use_heap); for (uint32_t i = 0; i < num_args; i++) { - if (UNEXPECTED(Z_TYPE(args[i]) != IS_ARRAY && !zend_parse_arg_str(&args[i], &strings[i], false, i + 2))) { + if (UNEXPECTED(Z_TYPE(args[i]) != IS_ARRAY && !zend_parse_arg_str(&args[i], &strings[i], true, i + 2))) { zend_wrong_parameter_type_error(i + 2, Z_EXPECTED_ARRAY_OR_STRING, &args[i]); goto out; } } for (uint32_t i = 0; i < num_args; i++) { + zend_string *result; if (Z_TYPE(args[i]) == IS_ARRAY) { zval *elem; ZEND_HASH_FOREACH_VAL(Z_ARRVAL(args[i]), elem) { - zend_string *result = try_setlocale_zval(cat, elem); + result = try_setlocale_zval(cat, elem); if (EG(exception)) { goto out; } @@ -4956,15 +4957,18 @@ PHP_FUNCTION(setlocale) goto out; } } ZEND_HASH_FOREACH_END(); + continue; + } else if (Z_ISNULL(args[i])) { + result = try_setlocale_str(cat, ZSTR_EMPTY_ALLOC()); } else { - zend_string *result = try_setlocale_str(cat, strings[i]); - if (EG(exception)) { - goto out; - } - if (result) { - RETVAL_STR(result); - goto out; - } + result = try_setlocale_str(cat, strings[i]); + } + if (EG(exception)) { + goto out; + } + if (result) { + RETVAL_STR(result); + goto out; } } diff --git a/ext/standard/tests/strings/gh18823_weak.phpt b/ext/standard/tests/strings/gh18823_weak.phpt index bc9611098a8db..2a2b82d9aaa32 100644 --- a/ext/standard/tests/strings/gh18823_weak.phpt +++ b/ext/standard/tests/strings/gh18823_weak.phpt @@ -27,6 +27,5 @@ try { echo $e->getMessage(), "\n"; } ?> ---EXPECTF-- -Deprecated: setlocale(): Passing null to parameter #2 ($locales) of type string is deprecated in %s on line %d +--EXPECT-- no diff --git a/ext/standard/tests/strings/gh19070.phpt b/ext/standard/tests/strings/gh19070.phpt new file mode 100644 index 0000000000000..e44696443cc97 --- /dev/null +++ b/ext/standard/tests/strings/gh19070.phpt @@ -0,0 +1,8 @@ +--TEST-- +GH-19070 (setlocale($type, NULL) should not be deprecated) +--FILE-- + +--EXPECTF-- +string(%d) "%s" From 2be3aa86f04be760cfc826f11c4d11dedd060ff9 Mon Sep 17 00:00:00 2001 From: Demon Date: Tue, 8 Jul 2025 13:51:03 +0800 Subject: [PATCH 2/6] Zend: fix undefined symbol 'execute_ex' on Windows ARM64 #19064; ext/gd: fix emmintrin.h not found on Windows ARM64 --- Zend/zend_vm_execute.h | 2 +- Zend/zend_vm_execute.skl | 2 +- ext/gd/libgd/gd_interpolation.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 25e537dc1c07a..96bdc01746ae6 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -55088,7 +55088,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_NULL_HANDLER(ZEND_OPCODE_HANDL # pragma GCC optimize("no-gcse") # pragma GCC optimize("no-ivopts") #endif -#ifdef _WIN64 +#if defined(_WIN64) && defined(_M_X64) /* See save_xmm_x86_64_ms_masm.asm */ void execute_ex_real(zend_execute_data *ex) #else diff --git a/Zend/zend_vm_execute.skl b/Zend/zend_vm_execute.skl index 5b4799cd67c2a..b1e26d002604c 100644 --- a/Zend/zend_vm_execute.skl +++ b/Zend/zend_vm_execute.skl @@ -5,7 +5,7 @@ # pragma GCC optimize("no-gcse") # pragma GCC optimize("no-ivopts") #endif -#ifdef _WIN64 +#if defined(_WIN64) && defined(_M_X64) /* See save_xmm_x86_64_ms_masm.asm */ void {%EXECUTOR_NAME%}_ex_real(zend_execute_data *ex) #else diff --git a/ext/gd/libgd/gd_interpolation.c b/ext/gd/libgd/gd_interpolation.c index 5481fa2a16b02..4aa2b79b7a7c8 100644 --- a/ext/gd/libgd/gd_interpolation.c +++ b/ext/gd/libgd/gd_interpolation.c @@ -62,7 +62,7 @@ #include "gdhelpers.h" #include "gd_intern.h" -#ifdef _MSC_VER +#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) # pragma optimize("t", on) # include #endif From 12fa8c637f9801f7b9574f152f31845403345d9a Mon Sep 17 00:00:00 2001 From: Demon Date: Thu, 10 Jul 2025 09:52:59 +0800 Subject: [PATCH 3/6] ext/gd: Drop useless and doubtful MSVC specific code (libgd/libgd@f1480ab) --- ext/gd/libgd/gd_interpolation.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ext/gd/libgd/gd_interpolation.c b/ext/gd/libgd/gd_interpolation.c index 4aa2b79b7a7c8..b3f391e6d20e9 100644 --- a/ext/gd/libgd/gd_interpolation.c +++ b/ext/gd/libgd/gd_interpolation.c @@ -62,11 +62,6 @@ #include "gdhelpers.h" #include "gd_intern.h" -#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) -# pragma optimize("t", on) -# include -#endif - #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) #endif From 2fa0e554500d6568f18eef08b34b6d5fd88fb6e9 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Thu, 10 Jul 2025 22:14:38 +0200 Subject: [PATCH 4/6] Update NEWS for GH-19068 --- NEWS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index d4354c12b08d0..2061e6d533820 100644 --- a/NEWS +++ b/NEWS @@ -11,7 +11,9 @@ PHP NEWS . Fixed bug GH-18907 (Leak when creating cycle in hook). (ilutov) . Fix OSS-Fuzz #427814456. (nielsdos) . Fix OSS-Fuzz #428983568 and #428760800. (nielsdos) - . Fixed bug GH-17204 -Wuseless-escape warnings emitted by re2c. (Peter Kokot) + . Fixed bug GH-17204 (-Wuseless-escape warnings emitted by re2c). (Peter Kokot) + . Fixed bug GH-19064 (Undefined symbol 'execute_ex' on Windows ARM64). + (Demon) - Curl: . Fix memory leaks when returning refcounted value from curl callback. From 974526b244e59eb38a66bd6b44030a7c6bd5e792 Mon Sep 17 00:00:00 2001 From: Demon Date: Thu, 10 Jul 2025 09:52:59 +0800 Subject: [PATCH 5/6] ext/gd: Drop useless and doubtful MSVC specific code (libgd/libgd@f1480ab) --- ext/gd/libgd/gd_interpolation.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ext/gd/libgd/gd_interpolation.c b/ext/gd/libgd/gd_interpolation.c index bc1b3d344e69e..5d9e991127c49 100644 --- a/ext/gd/libgd/gd_interpolation.c +++ b/ext/gd/libgd/gd_interpolation.c @@ -62,11 +62,6 @@ #include "gdhelpers.h" #include "gd_intern.h" -#ifdef _MSC_VER -# pragma optimize("t", on) -# include -#endif - #ifndef HAVE_FLOORF # define HAVE_FLOORF 0 #endif From 85a49d4198e55274ed222335a0e95d67d58ccf70 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Mon, 7 Jul 2025 14:58:47 +0100 Subject: [PATCH 6/6] ext/soap/php_http.c: Fix memory leak of header value --- NEWS | 1 + ext/soap/php_http.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index d0d8c25df5325..c653d946b90a1 100644 --- a/NEWS +++ b/NEWS @@ -45,6 +45,7 @@ PHP NEWS - SOAP: . Fixed bug GH-18990, bug #81029, bug #47314 (SOAP HTTP socket not closing on object destruction). (nielsdos) + . Fix memory leak when URL parsing fails in redirect. (Girgias) - Standard: . Fix misleading errors in printf(). (nielsdos) diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index 3dfafda4f9573..65ce38db38722 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -1128,11 +1128,11 @@ int make_http_soap_request(zval *this_ptr, if ((loc = get_http_header_value(ZSTR_VAL(http_headers), "Location: ")) != NULL) { php_url *new_url = php_url_parse(loc); + efree(loc); if (new_url != NULL) { zend_string_release_ex(http_headers, 0); zend_string_release_ex(http_body, 0); - efree(loc); if (new_url->scheme == NULL && new_url->path != NULL) { new_url->scheme = phpurl->scheme ? zend_string_copy(phpurl->scheme) : NULL; new_url->host = phpurl->host ? zend_string_copy(phpurl->host) : NULL;