Skip to content

Commit 8dd117f

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix GH-19722: Windows: _get_osfhandle asserts in debug mode when given a socket
2 parents aa82c9c + 94625a0 commit 8dd117f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ PHP NEWS
6060
. Fix arginfo/zpp violations when LIBXML_SCHEMAS_ENABLED is not available.
6161
(nielsdos)
6262

63+
- Windows:
64+
. Fix GH-19722 (_get_osfhandle asserts in debug mode when given a socket).
65+
(dktapps)
66+
6367
09 Oct 2025, PHP 8.4.14
6468

6569
- Core:

win32/select.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ PHPAPI int php_select(php_socket_t max_fd, fd_set *rfds, fd_set *wfds, fd_set *e
6262
/* build an array of handles for non-sockets */
6363
for (i = 0; (uint32_t)i < max_fd; i++) {
6464
if (SAFE_FD_ISSET(i, rfds) || SAFE_FD_ISSET(i, wfds) || SAFE_FD_ISSET(i, efds)) {
65-
handles[n_handles] = (HANDLE)(uintptr_t)_get_osfhandle(i);
66-
if (handles[n_handles] == INVALID_HANDLE_VALUE) {
65+
int _type;
66+
int _len = sizeof(_type);
67+
68+
if (getsockopt((SOCKET)i, SOL_SOCKET, SO_TYPE, (char*)&_type, &_len) == 0 || WSAGetLastError() != WSAENOTSOCK) {
6769
/* socket */
6870
if (SAFE_FD_ISSET(i, rfds)) {
6971
FD_SET((uint32_t)i, &sock_read);
@@ -78,8 +80,11 @@ PHPAPI int php_select(php_socket_t max_fd, fd_set *rfds, fd_set *wfds, fd_set *e
7880
sock_max_fd = i;
7981
}
8082
} else {
81-
handle_slot_to_fd[n_handles] = i;
82-
n_handles++;
83+
handles[n_handles] = (HANDLE)(uintptr_t)_get_osfhandle(i);
84+
if (handles[n_handles] != INVALID_HANDLE_VALUE) {
85+
handle_slot_to_fd[n_handles] = i;
86+
n_handles++;
87+
}
8388
}
8489
}
8590
}

0 commit comments

Comments
 (0)