Fixed bug #72075 (Referencing socket resources breaks stream_select)

This commit is contained in:
Xinchen Hui 2016-04-22 21:20:53 -07:00
parent 988bdd0908
commit 9eb7c8cd3b
3 changed files with 20 additions and 0 deletions

2
NEWS
View File

@ -37,6 +37,8 @@ PHP NEWS
. Fixed bug #68849 (bindValue is not using the right data type). (Anatol)
- Standard:
. Fixed bug #72075 (Referencing socket resources breaks stream_select).
(Laruence)
. Fixed bug #72031 (array_column() against an array of objects discards all
values matching null). (Nikita)

View File

@ -613,6 +613,7 @@ static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, php_socket_t
the higher bits of a SOCKET variable uninitialized on systems with little endian. */
php_socket_t this_fd;
ZVAL_DEREF(elem);
php_stream_from_zval_no_verify(stream, elem);
if (stream == NULL) {
continue;
@ -652,6 +653,7 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds)
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(stream_array), num_ind, key, elem) {
php_socket_t this_fd;
ZVAL_DEREF(elem);
php_stream_from_zval_no_verify(stream, elem);
if (stream == NULL) {
continue;
@ -698,6 +700,7 @@ static int stream_array_emulate_read_fd_set(zval *stream_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) {
ZVAL_DEREF(elem);
php_stream_from_zval_no_verify(stream, elem);
if (stream == NULL) {
continue;

View File

@ -0,0 +1,15 @@
--TEST--
Bug #72075 (Referencing socket resources breaks stream_select)
--FILE--
<?php
$r = [stream_socket_server("tcp://127.0.0.1:0", $errno, $errStr)];
$w = NULL;
$e = NULL;
// Without this line, all is well:
$dummy =& $r[0];
print stream_select($r, $w, $e, 0.5);
--EXPECT--
0