ID: 31213
Updated by: [EMAIL PROTECTED]
Reported By: mikael at SPAMMENOTchl dot chalmers dot se
-Status: Feedback
+Status: Assigned
Bug Type: Arrays related
Operating System: Linux
PHP Version: 4.3.9
-Assigned To:
+Assigned To: moriyoshi
New Comment:
Verified.
Previous Comments:
------------------------------------------------------------------------
[2004-12-22 00:44:46] [EMAIL PROTECTED]
Can you give some simpler example? (I'm a bit stupid and can't
understand why you would do something like that in a real-life code..)
------------------------------------------------------------------------
[2004-12-21 00:11:04] mikael at SPAMMENOTchl dot chalmers dot se
Description:
------------
In regard to bug #29493 (would have added a comment to it if I could)
--
This fix seems to have been backported to PHP 4.3.9, now we get other
errors.
In the example below $acopy is a reference to $arr['acopy'] and $a is
also a reference to $arr['acopy'], when actually $a should have been
separated from $arr['acopy'] when extract() makes the $acopy reference
to $arr['acopy'] since the array is created with 'acopy' => $a
$b, $arr['bref'] and $bref should and does however all point to the
same value as they should since the array is created with 'bref' =>
&$b
Reproduce code:
------------
Reproduce code:
---------------
$a = 1; $b = 1;
$arr = array('acopy' => $a, 'bref' => &$b);
extract($arr, EXTR_REFS);
$acopy++;
$bref++;
debug_zval_dump($a, $b, $arr, $acopy, $bref);
Expected result:
----------------
(As seen on PHP < 4.3.9):
$a: long(1) refcount(2)
$b: long(2) refcount(1)
$arr: array(2) refcount(2){
["acopy"]=>
&long(2) refcount(2)
["bref"]=>
&long(2) refcount(3)
}
$acopy: long(2) refcount(1)
$bref: long(2) refcount(1)
Note: Shouldn't the refcount of $a be == 1 instead of 2. $a should be a
separate zval while $arr['acopy'] and $acopy should be references to the
same value as indicated by the refcount of 2
Actual result:
--------------
$a is now == 2, when it should be == 1. Only $arr['acopy'] should be ==
2
$a: long(2) refcount(1)
$b: long(2) refcount(1)
$arr: array(2) refcount(2){
["acopy"]=>
&long(2) refcount(3)
["bref"]=>
&long(2) refcount(3)
}
$acopy: long(2) refcount(1)
$bref: long(2) refcount(1)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31213&edit=1