summaryrefslogtreecommitdiff
path: root/ext/sockets
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2006-07-30 11:54:11 +0000
committerAntony Dovgal <tony2001@php.net>2006-07-30 11:54:11 +0000
commit663672126109891b8d3d2fd55bfc17842c48832d (patch)
treeadcd5e38e50cb740e58d26435ead588c5d91ff33 /ext/sockets
parentc3d64c7024d49c82301c399eb20c659e7645d651 (diff)
downloadphp-git-663672126109891b8d3d2fd55bfc17842c48832d.tar.gz
improve checks and fix #38251
Diffstat (limited to 'ext/sockets')
-rw-r--r--ext/sockets/sockets.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index b2f2fc9ca8..ec14ce0d38 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -534,6 +534,7 @@ static int php_sock_array_to_fd_set(zval *sock_array, fd_set *fds, PHP_SOCKET *m
{
zval **element;
php_socket *php_sock;
+ int num = 0;
if (Z_TYPE_P(sock_array) != IS_ARRAY) return 0;
@@ -548,9 +549,10 @@ static int php_sock_array_to_fd_set(zval *sock_array, fd_set *fds, PHP_SOCKET *m
if (php_sock->bsd_socket > *max_fd) {
*max_fd = php_sock->bsd_socket;
}
+ num++;
}
- return 1;
+ return num ? 1 : 0;
}
static int php_sock_array_from_fd_set(zval *sock_array, fd_set *fds TSRMLS_DC)
@@ -559,6 +561,7 @@ static int php_sock_array_from_fd_set(zval *sock_array, fd_set *fds TSRMLS_DC)
zval **dest_element;
php_socket *php_sock;
HashTable *new_hash;
+ int num = 0;
if (Z_TYPE_P(sock_array) != IS_ARRAY) return 0;
@@ -576,6 +579,7 @@ static int php_sock_array_from_fd_set(zval *sock_array, fd_set *fds TSRMLS_DC)
zend_hash_next_index_insert(new_hash, (void *)element, sizeof(zval *), (void **)&dest_element);
if (dest_element) zval_add_ref(dest_element);
}
+ num++;
}
/* Destroy old array, add new one */
@@ -585,7 +589,7 @@ static int php_sock_array_from_fd_set(zval *sock_array, fd_set *fds TSRMLS_DC)
zend_hash_internal_pointer_reset(new_hash);
Z_ARRVAL_P(sock_array) = new_hash;
- return 1;
+ return num ? 1 : 0;
}
/* {{{ proto int socket_select(array &read_fds, array &write_fds, &array except_fds, int tv_sec[, int tv_usec])