helly           Tue Apr 13 15:06:16 2004 EDT

  Modified files:              
    /php-src/ext/spl    spl_array.c 
  Log:
  Bugfix #27979
  
http://cvs.php.net/diff.php/php-src/ext/spl/spl_array.c?r1=1.37&r2=1.38&ty=u
Index: php-src/ext/spl/spl_array.c
diff -u php-src/ext/spl/spl_array.c:1.37 php-src/ext/spl/spl_array.c:1.38
--- php-src/ext/spl/spl_array.c:1.37    Tue Apr 13 12:21:24 2004
+++ php-src/ext/spl/spl_array.c Tue Apr 13 15:06:16 2004
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_array.c,v 1.37 2004/04/13 16:21:24 stas Exp $ */
+/* $Id: spl_array.c,v 1.38 2004/04/13 19:06:16 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -328,18 +328,26 @@
 /* exceptions do not work yet
        php_set_error_handling(EH_THROW, zend_exception_get_default() TSRMLS_CC);*/
 
+       intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
+
        if (ZEND_NUM_ARGS() > 1 || zend_get_parameters_ex(1, &array) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       if (!HASH_OF(*array)) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Passed variable is not an 
array or object, using empty array instead");
-               php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
-               return;
+       if (Z_TYPE_PP(array) == IS_OBJECT && (Z_OBJ_HT_PP(array) == 
&spl_handler_ArrayObject || Z_OBJ_HT_PP(array) == &spl_handler_ArrayIterator)) {
+               spl_array_object *other  = 
(spl_array_object*)zend_object_store_get_object(*array TSRMLS_CC);
+               zval_dtor(intern->array);
+               FREE_ZVAL(intern->array);
+               intern->array = other->array;           
+       } else {
+               if (!HASH_OF(*array)) {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Passed variable 
is not an array or object, using empty array instead");
+                       php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
+                       return;
+               }
+               zval_dtor(intern->array);
+               FREE_ZVAL(intern->array);
+               intern->array = *array;
        }
-       intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
-       zval_dtor(intern->array);
-       FREE_ZVAL(intern->array);
-       intern->array = *array;
        ZVAL_ADDREF(intern->array);
 
        zend_hash_internal_pointer_reset_ex(HASH_OF(intern->array), &intern->pos);

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

Reply via email to