@@ -595,17 +595,13 @@ PHP_FUNCTION(stream_get_wrappers)
595595/* }}} */
596596
597597/* {{{ stream_select related functions */
598- static int stream_array_to_fd_set (zval * stream_array , fd_set * fds , php_socket_t * max_fd )
598+ static int stream_array_to_fd_set (const HashTable * stream_array , fd_set * fds , php_socket_t * max_fd )
599599{
600600 zval * elem ;
601601 php_stream * stream ;
602602 int cnt = 0 ;
603603
604- if (Z_TYPE_P (stream_array ) != IS_ARRAY ) {
605- return 0 ;
606- }
607-
608- ZEND_HASH_FOREACH_VAL (Z_ARRVAL_P (stream_array ), elem ) {
604+ ZEND_HASH_FOREACH_VAL (stream_array , elem ) {
609605 /* Temporary int fd is needed for the STREAM data type on windows, passing this_fd directly to php_stream_cast()
610606 would eventually bring a wrong result on x64. php_stream_cast() casts to int internally, and this will leave
611607 the higher bits of a SOCKET variable uninitialized on systems with little endian. */
@@ -634,7 +630,7 @@ static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, php_socket_t
634630 return cnt ? 1 : 0 ;
635631}
636632
637- static int stream_array_from_fd_set (zval * stream_array , fd_set * fds )
633+ static int stream_array_from_fd_set (zval * stream_array , const fd_set * fds )
638634{
639635 zval * elem , * dest_elem ;
640636 HashTable * ht ;
@@ -643,9 +639,7 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds)
643639 zend_string * key ;
644640 zend_ulong num_ind ;
645641
646- if (Z_TYPE_P (stream_array ) != IS_ARRAY ) {
647- return 0 ;
648- }
642+ ZEND_ASSERT (Z_TYPE_P (stream_array ) == IS_ARRAY );
649643 ht = zend_new_array (zend_hash_num_elements (Z_ARRVAL_P (stream_array )));
650644
651645 ZEND_HASH_FOREACH_KEY_VAL (Z_ARRVAL_P (stream_array ), num_ind , key , elem ) {
@@ -671,7 +665,6 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds)
671665
672666 zval_add_ref (dest_elem );
673667 ret ++ ;
674- continue ;
675668 }
676669 }
677670 } ZEND_HASH_FOREACH_END ();
@@ -692,9 +685,7 @@ static int stream_array_emulate_read_fd_set(zval *stream_array)
692685 zend_ulong num_ind ;
693686 zend_string * key ;
694687
695- if (Z_TYPE_P (stream_array ) != IS_ARRAY ) {
696- return 0 ;
697- }
688+ ZEND_ASSERT (Z_TYPE_P (stream_array ) == IS_ARRAY );
698689 ht = zend_new_array (zend_hash_num_elements (Z_ARRVAL_P (stream_array )));
699690
700691 ZEND_HASH_FOREACH_KEY_VAL (Z_ARRVAL_P (stream_array ), num_ind , key , elem ) {
@@ -717,7 +708,6 @@ static int stream_array_emulate_read_fd_set(zval *stream_array)
717708 }
718709 zval_add_ref (dest_elem );
719710 ret ++ ;
720- continue ;
721711 }
722712 } ZEND_HASH_FOREACH_END ();
723713
@@ -760,21 +750,21 @@ PHP_FUNCTION(stream_select)
760750 FD_ZERO (& efds );
761751
762752 if (r_array != NULL ) {
763- set_count = stream_array_to_fd_set (r_array , & rfds , & max_fd );
753+ set_count = stream_array_to_fd_set (Z_ARR_P ( r_array ) , & rfds , & max_fd );
764754 if (set_count > max_set_count )
765755 max_set_count = set_count ;
766756 sets += set_count ;
767757 }
768758
769759 if (w_array != NULL ) {
770- set_count = stream_array_to_fd_set (w_array , & wfds , & max_fd );
760+ set_count = stream_array_to_fd_set (Z_ARR_P ( w_array ) , & wfds , & max_fd );
771761 if (set_count > max_set_count )
772762 max_set_count = set_count ;
773763 sets += set_count ;
774764 }
775765
776766 if (e_array != NULL ) {
777- set_count = stream_array_to_fd_set (e_array , & efds , & max_fd );
767+ set_count = stream_array_to_fd_set (Z_ARR_P ( e_array ) , & efds , & max_fd );
778768 if (set_count > max_set_count )
779769 max_set_count = set_count ;
780770 sets += set_count ;
0 commit comments