moriyoshi               Wed Dec  4 11:44:24 2002 EDT

  Modified files:              (Branch: PHP_4_3)
    /php4/ext/standard  array.c 
  Log:
  MFH: fixed segfaults in array_walk() when keys are passed to cb by reference 
  
  
Index: php4/ext/standard/array.c
diff -u php4/ext/standard/array.c:1.199.2.5 php4/ext/standard/array.c:1.199.2.6
--- php4/ext/standard/array.c:1.199.2.5 Tue Dec  3 10:02:55 2002
+++ php4/ext/standard/array.c   Wed Dec  4 11:44:24 2002
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: array.c,v 1.199.2.5 2002/12/03 15:02:55 moriyoshi Exp $ */
+/* $Id: array.c,v 1.199.2.6 2002/12/04 16:44:24 moriyoshi Exp $ */
 
 #include "php.h"
 #include "php_ini.h"
@@ -953,9 +953,6 @@
        ulong  num_key;
        HashPosition pos;
 
-       /* Allocate space for key */
-       MAKE_STD_ZVAL(key);
-       
        /* Set up known arguments */
        args[1] = &key;
        args[2] = userdata;
@@ -964,6 +961,9 @@
 
        /* Iterate through hash */
        while (zend_hash_get_current_data_ex(target_hash, (void **)&args[0], &pos) == 
SUCCESS) {
+               /* Allocate space for key */
+               MAKE_STD_ZVAL(key);
+       
                /* Set up the key */
                if (zend_hash_get_current_key_ex(target_hash, &string_key, 
&string_key_len, &num_key, 0, &pos) == HASH_KEY_IS_LONG) {
                        Z_TYPE_P(key) = IS_LONG;
@@ -992,9 +992,9 @@
                        break;
                }
 
+               zval_ptr_dtor(&key);
                zend_hash_move_forward_ex(target_hash, &pos);
        }
-       zval_ptr_dtor(&key);
        
        return 0;
 }



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

Reply via email to