From: Nikita Popov Date: Mon, 22 Feb 2016 11:33:41 +0000 (+0100) Subject: Fix ArrayObject clone for certain USE_OTHER cases X-Git-Tag: php-7.0.5RC1~83 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fd6ac610641e48db1352c12de022500dd0272963;p=php Fix ArrayObject clone for certain USE_OTHER cases We can't simply use HASH_OF, need to use the usual hash table getter. --- diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 83c1f288ff..d3603a3b32 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -167,7 +167,8 @@ static zend_object *spl_array_object_new_ex(zend_class_entry *class_type, zval * if (other->ar_flags & SPL_ARRAY_IS_SELF) { ZVAL_UNDEF(&intern->array); } else if (Z_OBJ_HT_P(orig) == &spl_handler_ArrayObject) { - ZVAL_ARR(&intern->array, zend_array_dup(HASH_OF(&other->array))); + ZVAL_ARR(&intern->array, + zend_array_dup(spl_array_get_hash_table(&other->array, 0))); } else { ZEND_ASSERT(Z_OBJ_HT_P(orig) == &spl_handler_ArrayIterator); ZVAL_COPY(&intern->array, orig); diff --git a/ext/spl/tests/ArrayObject_clone_other_std_props.phpt b/ext/spl/tests/ArrayObject_clone_other_std_props.phpt new file mode 100644 index 0000000000..688954c3d7 --- /dev/null +++ b/ext/spl/tests/ArrayObject_clone_other_std_props.phpt @@ -0,0 +1,23 @@ +--TEST-- +Clone ArrayObject using other with STD_PROP_LIST +--FILE-- + +--EXPECT-- +object(ArrayObject)#3 (1) { + ["storage":"ArrayObject":private]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +}