@@ -613,7 +613,7 @@ static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, php_socket_t
613613 /* Temporary int fd is needed for the STREAM data type on windows, passing this_fd directly to php_stream_cast()
614614 would eventually bring a wrong result on x64. php_stream_cast() casts to int internally, and this will leave
615615 the higher bits of a SOCKET variable uninitialized on systems with little endian. */
616- int tmp_fd ;
616+ php_socket_t this_fd ;
617617
618618 php_stream_from_zval_no_verify (stream , elem );
619619 if (stream == NULL ) {
@@ -624,9 +624,7 @@ static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, php_socket_t
624624 * when casting. It is only used here so that the buffered data warning
625625 * is not displayed.
626626 * */
627- if (SUCCESS == php_stream_cast (stream , PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL , (void * )& tmp_fd , 1 ) && tmp_fd != -1 ) {
628-
629- php_socket_t this_fd = (php_socket_t )tmp_fd ;
627+ if (SUCCESS == php_stream_cast (stream , PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL , (void * )& this_fd , 1 ) && this_fd != -1 ) {
630628
631629 PHP_SAFE_FD_SET (this_fd , fds );
632630
@@ -660,10 +658,7 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
660658 char * key ;
661659 uint key_len ;
662660 ulong num_ind ;
663- /* Temporary int fd is needed for the STREAM data type on windows, passing this_fd directly to php_stream_cast()
664- would eventually bring a wrong result on x64. php_stream_cast() casts to int internally, and this will leave
665- the higher bits of a SOCKET variable uninitialized on systems with little endian. */
666- int tmp_fd ;
661+ php_socket_t this_fd ;
667662
668663
669664 type = zend_hash_get_current_key_ex (Z_ARRVAL_P (stream_array ),
@@ -682,10 +677,7 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
682677 * when casting. It is only used here so that the buffered data warning
683678 * is not displayed.
684679 */
685- if (SUCCESS == php_stream_cast (stream , PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL , (void * )& tmp_fd , 1 ) && tmp_fd != -1 ) {
686-
687- php_socket_t this_fd = (php_socket_t )tmp_fd ;
688-
680+ if (SUCCESS == php_stream_cast (stream , PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL , (void * )& this_fd , 1 ) && this_fd != SOCK_ERR ) {
689681 if (PHP_SAFE_FD_ISSET (this_fd , fds )) {
690682 if (type == HASH_KEY_IS_LONG ) {
691683 zend_hash_index_update (new_hash , num_ind , (void * )elem , sizeof (zval * ), (void * * )& dest_elem );
0 commit comments