From: Sara Golemon Date: Thu, 19 Oct 2006 22:20:44 +0000 (+0000) Subject: Fix working with ArrayObjects which contain arrays. X-Git-Tag: RELEASE_1_0_0RC1~1237 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=631b9b016e101c15e8c02ca1624336765b84d316;p=php Fix working with ArrayObjects which contain arrays. --- diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 18f3eb9d50..4322d7363b 100755 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -300,6 +300,8 @@ static zval **spl_array_get_dimension_ptr_ptr(int check_inherited, zval *object, static zval *spl_array_read_dimension_ex(int check_inherited, zval *object, zval *offset, int type TSRMLS_DC) /* {{{ */ { + zval **ret; + if (check_inherited) { spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); if (intern->fptr_offset_get) { @@ -316,7 +318,30 @@ static zval *spl_array_read_dimension_ex(int check_inherited, zval *object, zval return EG(uninitialized_zval_ptr); } } - return *spl_array_get_dimension_ptr_ptr(check_inherited, object, offset, type TSRMLS_CC); + ret = spl_array_get_dimension_ptr_ptr(check_inherited, object, offset, type TSRMLS_CC); + + /* When in a write context, + * ZE has to be fooled into thinking this is in a reference set + * by separating (if necessary) and returning as an is_ref=1 zval (even if refcount == 1) */ + if ((type == BP_VAR_W || type == BP_VAR_RW) && !(*ret)->is_ref) { + if ((*ret)->refcount > 1) { + zval *newval; + + /* Separate */ + MAKE_STD_ZVAL(newval); + *newval = **ret; + zval_copy_ctor(newval); + newval->refcount = 1; + + /* Replace */ + (*ret)->refcount--; + *ret = newval; + } + + (*ret)->is_ref = 1; + } + + return *ret; } /* }}} */ static zval *spl_array_read_dimension(zval *object, zval *offset, int type TSRMLS_DC) /* {{{ */