felipe Thu, 02 Jun 2011 00:40:27 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=311721
Log: - Fixed bug #54970 (SplFixedArray::setSize() isn't resizing) Bug: http://bugs.php.net/54970 (Open) SplFixedArray::setSize() isn't resizing Changed paths: U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/spl/spl_fixedarray.c A php/php-src/branches/PHP_5_3/ext/spl/tests/bug54970.phpt U php/php-src/branches/PHP_5_4/ext/spl/spl_fixedarray.c A php/php-src/branches/PHP_5_4/ext/spl/tests/bug54970.phpt U php/php-src/trunk/ext/spl/spl_fixedarray.c A php/php-src/trunk/ext/spl/tests/bug54970.phpt Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2011-06-02 00:05:23 UTC (rev 311720) +++ php/php-src/branches/PHP_5_3/NEWS 2011-06-02 00:40:27 UTC (rev 311721) @@ -154,6 +154,7 @@ . Fixed bug #51958 (socket_accept() fails on IPv6 server sockets). (Gustavo) - SPL extension: + . Fixed bug #54970 (SplFixedArray::setSize() isn't resizing). (Felipe) . Fixed bug #54384 (Dual iterators, GlobIterator, SplFileObject and SplTempFileObject crash when user-space classes don't call the paren constructor). (Gustavo) Modified: php/php-src/branches/PHP_5_3/ext/spl/spl_fixedarray.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/spl/spl_fixedarray.c 2011-06-02 00:05:23 UTC (rev 311720) +++ php/php-src/branches/PHP_5_3/ext/spl/spl_fixedarray.c 2011-06-02 00:40:27 UTC (rev 311721) @@ -153,6 +153,8 @@ int i = 0; if (intern->array) { + int j = zend_hash_num_elements(intern->std.properties); + for (i = 0; i < intern->array->size; i++) { if (intern->array->elements[i]) { zend_hash_index_update(intern->std.properties, i, (void *)&intern->array->elements[i], sizeof(zval *), NULL); @@ -165,6 +167,11 @@ Z_ADDREF_P(EG(uninitialized_zval_ptr)); } } + if (j > intern->array->size) { + for (i = intern->array->size; i < j; ++i) { + zend_hash_index_del(intern->std.properties, i); + } + } } return intern->std.properties; Added: php/php-src/branches/PHP_5_3/ext/spl/tests/bug54970.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/spl/tests/bug54970.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/ext/spl/tests/bug54970.phpt 2011-06-02 00:40:27 UTC (rev 311721) @@ -0,0 +1,33 @@ +--TEST-- +Bug #54970 (SplFixedArray::setSize() isn't resizing) +--FILE-- +<?php + +$fa = new SplFixedArray(2); +$fa[0] = 'Hello'; +$fa[1] = 'World'; +$fa->setSize(3); +$fa[2] = '!'; +var_dump($fa); +$fa->setSize(2); +var_dump($fa); +var_dump($fa->getSize()); + + +?> +--EXPECTF-- +object(SplFixedArray)#%d (3) { + [0]=> + string(5) "Hello" + [1]=> + string(5) "World" + [2]=> + string(1) "!" +} +object(SplFixedArray)#%d (2) { + [0]=> + string(5) "Hello" + [1]=> + string(5) "World" +} +int(2) Modified: php/php-src/branches/PHP_5_4/ext/spl/spl_fixedarray.c =================================================================== --- php/php-src/branches/PHP_5_4/ext/spl/spl_fixedarray.c 2011-06-02 00:05:23 UTC (rev 311720) +++ php/php-src/branches/PHP_5_4/ext/spl/spl_fixedarray.c 2011-06-02 00:40:27 UTC (rev 311721) @@ -154,6 +154,8 @@ int i = 0; if (intern->array) { + int j = zend_hash_num_elements(ht); + for (i = 0; i < intern->array->size; i++) { if (intern->array->elements[i]) { zend_hash_index_update(ht, i, (void *)&intern->array->elements[i], sizeof(zval *), NULL); @@ -166,6 +168,11 @@ Z_ADDREF_P(EG(uninitialized_zval_ptr)); } } + if (j > intern->array->size) { + for (i = intern->array->size; i < j; ++i) { + zend_hash_index_del(ht, i); + } + } } return ht; Added: php/php-src/branches/PHP_5_4/ext/spl/tests/bug54970.phpt =================================================================== --- php/php-src/branches/PHP_5_4/ext/spl/tests/bug54970.phpt (rev 0) +++ php/php-src/branches/PHP_5_4/ext/spl/tests/bug54970.phpt 2011-06-02 00:40:27 UTC (rev 311721) @@ -0,0 +1,33 @@ +--TEST-- +Bug #54970 (SplFixedArray::setSize() isn't resizing) +--FILE-- +<?php + +$fa = new SplFixedArray(2); +$fa[0] = 'Hello'; +$fa[1] = 'World'; +$fa->setSize(3); +$fa[2] = '!'; +var_dump($fa); +$fa->setSize(2); +var_dump($fa); +var_dump($fa->getSize()); + + +?> +--EXPECTF-- +object(SplFixedArray)#%d (3) { + [0]=> + string(5) "Hello" + [1]=> + string(5) "World" + [2]=> + string(1) "!" +} +object(SplFixedArray)#%d (2) { + [0]=> + string(5) "Hello" + [1]=> + string(5) "World" +} +int(2) Modified: php/php-src/trunk/ext/spl/spl_fixedarray.c =================================================================== --- php/php-src/trunk/ext/spl/spl_fixedarray.c 2011-06-02 00:05:23 UTC (rev 311720) +++ php/php-src/trunk/ext/spl/spl_fixedarray.c 2011-06-02 00:40:27 UTC (rev 311721) @@ -154,6 +154,8 @@ int i = 0; if (intern->array) { + int j = zend_hash_num_elements(ht); + for (i = 0; i < intern->array->size; i++) { if (intern->array->elements[i]) { zend_hash_index_update(ht, i, (void *)&intern->array->elements[i], sizeof(zval *), NULL); @@ -166,6 +168,11 @@ Z_ADDREF_P(EG(uninitialized_zval_ptr)); } } + if (j > intern->array->size) { + for (i = intern->array->size; i < j; ++i) { + zend_hash_index_del(ht, i); + } + } } return ht; Added: php/php-src/trunk/ext/spl/tests/bug54970.phpt =================================================================== --- php/php-src/trunk/ext/spl/tests/bug54970.phpt (rev 0) +++ php/php-src/trunk/ext/spl/tests/bug54970.phpt 2011-06-02 00:40:27 UTC (rev 311721) @@ -0,0 +1,33 @@ +--TEST-- +Bug #54970 (SplFixedArray::setSize() isn't resizing) +--FILE-- +<?php + +$fa = new SplFixedArray(2); +$fa[0] = 'Hello'; +$fa[1] = 'World'; +$fa->setSize(3); +$fa[2] = '!'; +var_dump($fa); +$fa->setSize(2); +var_dump($fa); +var_dump($fa->getSize()); + + +?> +--EXPECTF-- +object(SplFixedArray)#%d (3) { + [0]=> + string(5) "Hello" + [1]=> + string(5) "World" + [2]=> + string(1) "!" +} +object(SplFixedArray)#%d (2) { + [0]=> + string(5) "Hello" + [1]=> + string(5) "World" +} +int(2)
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php