felipe          Thu Feb 21 02:34:50 2008 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src/ext/sockets        sockets.c 
    /php-src    NEWS 
  Log:
  Fixed Bug #44197 (socket array keys lost on socket_select)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.171.2.9.2.15&r2=1.171.2.9.2.16&diff_format=u
Index: php-src/ext/sockets/sockets.c
diff -u php-src/ext/sockets/sockets.c:1.171.2.9.2.15 
php-src/ext/sockets/sockets.c:1.171.2.9.2.16
--- php-src/ext/sockets/sockets.c:1.171.2.9.2.15        Mon Dec 31 07:20:11 2007
+++ php-src/ext/sockets/sockets.c       Thu Feb 21 02:34:50 2008
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sockets.c,v 1.171.2.9.2.15 2007/12/31 07:20:11 sebastian Exp $ */
+/* $Id: sockets.c,v 1.171.2.9.2.16 2008/02/21 02:34:50 felipe Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -584,7 +584,10 @@
        zval            **dest_element;
        php_socket      *php_sock;
        HashTable       *new_hash;
-       int                     num = 0;
+       char            *key;
+       int                     num;
+       ulong       num_key;
+       uint            key_len;
 
        if (Z_TYPE_P(sock_array) != IS_ARRAY) return 0;
 
@@ -599,7 +602,14 @@
 
                if (PHP_SAFE_FD_ISSET(php_sock->bsd_socket, fds)) {
                        /* Add fd to new array */
-                       zend_hash_next_index_insert(new_hash, (void *)element, 
sizeof(zval *), (void **)&dest_element);
+                       switch 
(zend_hash_get_current_key_ex(Z_ARRVAL_P(sock_array), &key, &key_len, &num_key, 
0, NULL)) {
+                               case HASH_KEY_IS_STRING:
+                                       zend_hash_add(new_hash, key, key_len, 
(void *)element, sizeof(zval *), (void **)&dest_element);
+                                       break;
+                               case HASH_KEY_IS_LONG:
+                                       zend_hash_index_update(new_hash, 
num_key, (void *)element, sizeof(zval *), (void **)&dest_element);
+                                       break;
+                       }
                        if (dest_element) zval_add_ref(dest_element);
                }
                num++;
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.1087&r2=1.2027.2.547.2.1088&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.1087 php-src/NEWS:1.2027.2.547.2.1088
--- php-src/NEWS:1.2027.2.547.2.1087    Wed Feb 20 22:08:18 2008
+++ php-src/NEWS        Thu Feb 21 02:34:50 2008
@@ -11,6 +11,7 @@
 - Upgraded PCRE to version 7.6 (Nuno)
 
 
+- Fixed Bug #44197 (socket array keys lost on socket_select). (Felipe)
 - Fixed Bug #44191 (preg_grep messes up array index). (Felipe)
 - Fixed bug #44184 (Double free of loop-variable on exception). (Dmitry)
 - Fixed bug #44171 (Invalid FETCH_COLUMN index does not raise an error). (Ilia)

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

Reply via email to