php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34518 copy-on-write error
Submitted: 2005-09-16 00:02 UTC Modified: 2005-09-16 17:25 UTC
From: genome at digitaljunkies dot ca Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2005-09-15 OS: *
Private report: No CVE-ID: None
 [2005-09-16 00:02 UTC] genome at digitaljunkies dot ca
Description:
------------
Altering a subindex of a copy of an array alters the original array as well.  Similar to bug#27381.  Altering a root index does not exhibit this behaviour.

Reproduce code:
---------------
<?php

$arr = array(1,2,3);
$arr["foo"] = array(4,5,6);
$copy = $arr;

unset($copy["foo"][0]);
print_r($arr);

?>

Expected result:
----------------
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [foo] => Array
        (
            [0] => 4
            [1] => 5
            [2] => 6
        )

)


Actual result:
--------------
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [foo] => Array
        (
            [1] => 5
            [2] => 6
        )

)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-16 10:09 UTC] sniper@php.net
Dmitry, I think it was you who fixed the problem in bug #27381, can you check this one out?

 [2005-09-16 17:25 UTC] dmitry@php.net
Fixed in CVS HEAD and PHP_5_1.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 03:01:29 2024 UTC