summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2008-02-21 02:34:50 +0000
committerFelipe Pena <felipe@php.net>2008-02-21 02:34:50 +0000
commite0379278afafc035c3af09ccb071d8cf7a5f815c (patch)
tree053bfee6d6e1d46bd95ec3add432f9b38496b667
parent50bdcc203b2ac530282ea247550db7733d559c8b (diff)
downloadphp-git-e0379278afafc035c3af09ccb071d8cf7a5f815c.tar.gz
Fixed Bug #44197 (socket array keys lost on socket_select)
-rw-r--r--NEWS1
-rw-r--r--ext/sockets/sockets.c14
2 files changed, 13 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 54a26a9e06..6a555c5154 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ PHP NEWS
- Upgraded PCRE to version 7.6 (Nuno)
+- Fixed Bug #44197 (socket array keys lost on socket_select). (Felipe)
- Fixed Bug #44191 (preg_grep messes up array index). (Felipe)
- Fixed bug #44184 (Double free of loop-variable on exception). (Dmitry)
- Fixed bug #44171 (Invalid FETCH_COLUMN index does not raise an error). (Ilia)
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index 55039e6991..124595185f 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -584,7 +584,10 @@ 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;
+ char *key;
+ int num;
+ ulong num_key;
+ uint key_len;
if (Z_TYPE_P(sock_array) != IS_ARRAY) return 0;
@@ -599,7 +602,14 @@ static int php_sock_array_from_fd_set(zval *sock_array, fd_set *fds TSRMLS_DC) /
if (PHP_SAFE_FD_ISSET(php_sock->bsd_socket, fds)) {
/* Add fd to new array */
- zend_hash_next_index_insert(new_hash, (void *)element, sizeof(zval *), (void **)&dest_element);
+ switch (zend_hash_get_current_key_ex(Z_ARRVAL_P(sock_array), &key, &key_len, &num_key, 0, NULL)) {
+ case HASH_KEY_IS_STRING:
+ zend_hash_add(new_hash, key, key_len, (void *)element, sizeof(zval *), (void **)&dest_element);
+ break;
+ case HASH_KEY_IS_LONG:
+ zend_hash_index_update(new_hash, num_key, (void *)element, sizeof(zval *), (void **)&dest_element);
+ break;
+ }
if (dest_element) zval_add_ref(dest_element);
}
num++;