Skip to content

Commit 9a74b23

Browse files
committed
Fixed bug #78038 socket_select with references
1 parent fa6a448 commit 9a74b23

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ PHP NEWS
1414
. Fixed bug #77956 (When mysqli.allow_local_infile = Off, use a meaningful
1515
error message). (Sjon Hortensius)
1616

17+
- Sockets:
18+
. Fixed bug #78038 (Socket_select fails when resource array contains
19+
references). (Nikita)
20+
1721
30 May 2019, PHP 7.2.19
1822

1923
- FPM:

ext/sockets/sockets.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,7 @@ static int php_sock_array_to_fd_set(zval *sock_array, fd_set *fds, PHP_SOCKET *m
853853
if (Z_TYPE_P(sock_array) != IS_ARRAY) return 0;
854854

855855
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(sock_array), element) {
856+
ZVAL_DEREF(element);
856857
php_sock = (php_socket*) zend_fetch_resource_ex(element, le_socket_name, le_socket);
857858
if (!php_sock) continue; /* If element is not a resource, skip it */
858859

@@ -881,6 +882,7 @@ static int php_sock_array_from_fd_set(zval *sock_array, fd_set *fds) /* {{{ */
881882

882883
array_init(&new_hash);
883884
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(sock_array), num_key, key, element) {
885+
ZVAL_DEREF(element);
884886
php_sock = (php_socket*) zend_fetch_resource_ex(element, le_socket_name, le_socket);
885887
if (!php_sock) continue; /* If element is not a resource, skip it */
886888

ext/sockets/tests/socket_select.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ socket_create_pair($domain, SOCK_STREAM, 0, $sockets);
1717

1818
$write = null;
1919
$except = null;
20+
$ref =& $sockets[0]; // bug #78038
2021
var_dump(socket_select($sockets, $write, $except, 0));
2122
--EXPECT--
2223
int(0)

0 commit comments

Comments
 (0)