tony2001                Sun Jul 30 11:54:11 2006 UTC

  Modified files:              
    /php-src/ext/sockets        sockets.c 
  Log:
  improve checks and fix #38251
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.180&r2=1.181&diff_format=u
Index: php-src/ext/sockets/sockets.c
diff -u php-src/ext/sockets/sockets.c:1.180 php-src/ext/sockets/sockets.c:1.181
--- php-src/ext/sockets/sockets.c:1.180 Tue Jun 13 13:12:19 2006
+++ php-src/ext/sockets/sockets.c       Sun Jul 30 11:54:11 2006
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sockets.c,v 1.180 2006/06/13 13:12:19 dmitry Exp $ */
+/* $Id: sockets.c,v 1.181 2006/07/30 11:54:11 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -534,6 +534,7 @@
 {
        zval            **element;
        php_socket      *php_sock;
+       int                     num = 0;
        
        if (Z_TYPE_P(sock_array) != IS_ARRAY) return 0;
 
@@ -548,9 +549,10 @@
                if (php_sock->bsd_socket > *max_fd) {
                        *max_fd = php_sock->bsd_socket;
                }
+               num++;
        }
 
-       return 1;
+       return num ? 1 : 0;
 }
 
 static int php_sock_array_from_fd_set(zval *sock_array, fd_set *fds TSRMLS_DC)
@@ -559,6 +561,7 @@
        zval            **dest_element;
        php_socket      *php_sock;
        HashTable       *new_hash;
+       int                     num = 0;
 
        if (Z_TYPE_P(sock_array) != IS_ARRAY) return 0;
 
@@ -576,6 +579,7 @@
                        zend_hash_next_index_insert(new_hash, (void *)element, 
sizeof(zval *), (void **)&dest_element);
                        if (dest_element) zval_add_ref(dest_element);
                }
+               num++;
        }
 
        /* Destroy old array, add new one */
@@ -585,7 +589,7 @@
        zend_hash_internal_pointer_reset(new_hash);
        Z_ARRVAL_P(sock_array) = new_hash;
 
-       return 1;
+       return num ? 1 : 0;
 }
 
 /* {{{ proto int socket_select(array &read_fds, array &write_fds, &array 
except_fds, int tv_sec[, int tv_usec])

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to