ID: 37742
Updated by: [EMAIL PROTECTED]
Reported By: eric dot daspet at survol dot net
-Status: Open
+Status: Assigned
Bug Type: SPL related
Operating System: MS Windows XP
PHP Version: 5.1.4
-Assigned To:
+Assigned To: helly
New Comment:
Valgrind also reports several errors in this code:
<?php
$ao = new ArrayObject( $_GET ) ;
unset( $ao['index']['i'] ) ;
?>
==2182== Invalid read of size 4
==2182== at 0x82151BC: _zval_ptr_dtor (zend_execute_API.c:393)
==2182== by 0x821E7D8: _zval_ptr_dtor_wrapper
(zend_variables.c:175)
==2182== by 0x822818A: zend_hash_destroy (zend_hash.c:521)
==2182== by 0x821E9EC: _zval_dtor_func (zend_variables.c:43)
==2182== by 0x82151FD: _zval_ptr_dtor (zend_variables.h:35)
==2182== by 0x821E7D8: _zval_ptr_dtor_wrapper
(zend_variables.c:175)
==2182== by 0x8227EA8: zend_hash_apply_deleter (zend_hash.c:576)
==2182== by 0x82280A6: zend_hash_graceful_reverse_destroy
(zend_hash.c:642)
==2182== by 0x821760C: shutdown_executor (zend_execute_API.c:221)
==2182== by 0x821F5C6: zend_deactivate (zend.c:854)
==2182== by 0x81E6E94: php_request_shutdown (main.c:1300)
==2182== by 0x8288B65: main (cgi_main.c:1667)
etc...
Previous Comments:
------------------------------------------------------------------------
[2006-06-08 13:10:53] eric dot daspet at survol dot net
Well, sorry, I have put Actual Result and Expected result in the wrong
order.
------------------------------------------------------------------------
[2006-06-08 12:45:28] eric dot daspet at survol dot net
Description:
------------
When a multidimentional superglobal is used to feed ArrayObjet, the
first unset of a sub-index is ignored.
- it is ok with a "normal" array, I've seen this only with $_REQUEST
and $_GET
- it is ok with $_GET as a simple array (one dimension)
- the second call to unset() succeed, either if is the exact same call
or if I try to unset another index, only the first fails
Reproduce code:
---------------
<?php
// call the script with ?index[i]=1&index[j]=2
$ao = new ArrayObject( $_GET ) ;
unset( $ao['index']['i'] ) ; // ignored
var_dump($ao) ;
unset( $ao['index']['j'] ) ; // ok
var_dump($ao) ;
unset( $ao['index']['i'] ) ; // ok
var_dump($ao) ;
Expected result:
----------------
object(ArrayObject)#1 (1) {
["index"]=> array(2) {
["i"]=> string(1) "1"
["j"]=> string(1) "2"
}
}
object(ArrayObject)#1 (1) {
["index"]=> array(1) {
["i"]=> string(1) "1"
}
}
object(ArrayObject)#1 (1) {
["index"]=> array(0) {
}
}
Actual result:
--------------
object(ArrayObject)#1 (1) {
["index"]=> array(1) {
["j"]=> string(1) "1"
}
}
object(ArrayObject)#1 (1) {
["index"]=> array(0) {
}
}
object(ArrayObject)#1 (1) {
["index"]=> array(0) {
}
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37742&edit=1