summaryrefslogtreecommitdiff
path: root/ext/standard/streamsfuncs.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/streamsfuncs.c')
-rw-r--r--ext/standard/streamsfuncs.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c
index 2654382906..9d725db919 100644
--- a/ext/standard/streamsfuncs.c
+++ b/ext/standard/streamsfuncs.c
@@ -710,6 +710,8 @@ static int stream_array_emulate_read_fd_set(zval *stream_array)
zval *elem, *dest_elem, new_array;
php_stream *stream;
int ret = 0;
+ zend_ulong num_ind;
+ zend_string *key;
if (Z_TYPE_P(stream_array) != IS_ARRAY) {
return 0;
@@ -717,7 +719,7 @@ static int stream_array_emulate_read_fd_set(zval *stream_array)
ZVAL_NEW_ARR(&new_array);
zend_hash_init(Z_ARRVAL(new_array), zend_hash_num_elements(Z_ARRVAL_P(stream_array)), NULL, ZVAL_PTR_DTOR, 0);
- ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(stream_array), elem) {
+ ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(stream_array), num_ind, key, elem) {
ZVAL_DEREF(elem);
php_stream_from_zval_no_verify(stream, elem);
if (stream == NULL) {
@@ -730,10 +732,12 @@ static int stream_array_emulate_read_fd_set(zval *stream_array)
* This branch of code also allows blocking streams with buffered data to
* operate correctly in stream_select.
* */
- dest_elem = zend_hash_next_index_insert(Z_ARRVAL(new_array), elem);
- if (dest_elem) {
- zval_add_ref(dest_elem);
+ if (!key) {
+ dest_elem = zend_hash_index_update(Z_ARRVAL(new_array), num_ind, elem);
+ } else {
+ dest_elem = zend_hash_update(Z_ARRVAL(new_array), key, elem);
}
+ zval_add_ref(dest_elem);
ret++;
continue;
}