Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002930 [Quercus] minor always 09-12-08 15:42 09-12-08 17:25
Reporter koreth View Status public  
Assigned To nam
Priority normal Resolution fixed  
Status closed   Product Version 3.2.1
Summary 0002930: array_fill_keys() needs to copy, not reference, values
Description <?php
$foo = array_fill_keys(array('a','b'), array());
$foo['a'][] = 'bar';
print $foo['b'][0];

In Vanilla PHP, this doesn't print anything since $foo['b'] is empty. In Quercus it prints 'bar' because $foo['b'] refers to the same underlying array as $foo['a'].
Additional Information Patch that seems to fix it:

--- a/modules/quercus/src/com/caucho/quercus/lib/ArrayModule.java
+++ b/modules/quercus/src/com/caucho/quercus/lib/ArrayModule.java
@@ -1998,7 +1998,7 @@
     Iterator<Value> iter = keyArray.getValueIterator(env);
     
     while (iter.hasNext()) {
- array.put(iter.next(), value);
+ array.put(iter.next(), value.copy());
     }
     
     return array;
Attached Files

- Relationships

- Notes
(0003435)
nam
09-12-08 17:25

php/1770

It appears that a couple of other ArrayModule functions may also be affected.
 

- Issue History
Date Modified Username Field Change
09-12-08 15:42 koreth New Issue
09-12-08 17:00 nam Status new => assigned
09-12-08 17:00 nam Assigned To  => nam
09-12-08 17:25 nam Status assigned => closed
09-12-08 17:25 nam Note Added: 0003435
09-12-08 17:25 nam Resolution open => fixed
09-12-08 17:25 nam Fixed in Version  => 3.2.1


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
29 total queries executed.
26 unique queries executed.
Powered by Mantis Bugtracker