[php-src] master: Merge branch 'PHP-8.6'
| From: | David Carlier | Date: | Thu, 12 Nov 2026 18:32:03 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.6' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143649@lists.php.net to get a copy of this message | ||
Author: David Carlier (devnexen)
Date: 2026-11-12T18:30:43Z
Commit: https://github.com/php/php-src/commit/a06202113dae162a7019bb381787df25c365cec8
Raw diff: https://github.com/php/php-src/commit/a06202113dae162a7019bb381787df25c365cec8.diff
Merge branch 'PHP-8.6'
* PHP-8.6:
ext/sockets: Accept an empty packed hints array in socket_addrinfo_lookup()
Changed paths:
A ext/sockets/tests/socket_addrinfo_lookup_empty_packed_hints.phpt
M ext/sockets/sockets.c
Diff:
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index 6776ae4ee2f3..c58aa0936285 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -2825,7 +2825,7 @@ PHP_FUNCTION(socket_addrinfo_lookup)
# endif
#endif
- if (zhints) {
+ if (zhints && zend_hash_num_elements(Z_ARRVAL_P(zhints)) > 0) {
if (UNEXPECTED(HT_IS_PACKED(Z_ARRVAL_P(zhints)))) {
zend_argument_value_error(3, "must only contain array keys \"ai_flags\",
\"ai_socktype\", "
"\"ai_protocol\", or \"ai_family\"");
diff --git a/ext/sockets/tests/socket_addrinfo_lookup_empty_packed_hints.phpt
b/ext/sockets/tests/socket_addrinfo_lookup_empty_packed_hints.phpt
new file mode 100644
index 000000000000..6905a1bad17d
--- /dev/null
+++ b/ext/sockets/tests/socket_addrinfo_lookup_empty_packed_hints.phpt
@@ -0,0 +1,21 @@
+--TEST--
+socket_addrinfo_lookup(): an empty packed hints array is accepted like []
+--EXTENSIONS--
+sockets
+--FILE--
+<?php
+$hints = [1];
+unset($hints[0]);
+var_dump(count($hints), $hints === []);
+var_dump(count(socket_addrinfo_lookup('127.0.0.1', '80', $hints)) ===
count(socket_addrinfo_lookup('127.0.0.1', '80', [])));
+try {
+ socket_addrinfo_lookup('127.0.0.1', '80', [1]);
+} catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+int(0)
+bool(true)
+bool(true)
+ValueError: socket_addrinfo_lookup(): Argument #3 ($hints) must only contain array keys
"ai_flags", "ai_socktype", "ai_protocol", or "ai_family"