php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35239 Objects can lose references
Submitted: 2005-11-16 12:05 UTC Modified: 2005-11-16 13:28 UTC
From: dmitry@php.net Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 6CVS-2005-11-16 (CVS) OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dmitry@php.net
New email:
PHP Version: OS:

 

 [2005-11-16 12:05 UTC] dmitry@php.net
Description:
------------
Assignment by reference to property may lose reference.

Reproduce code:
---------------
<?php
$a = new stdClass; 
$a->x0 = new stdClass;
$a->x0->y0 = 'a';
$a->x0->y1 =& $a->x0;
$a->x0->y2 =& $a->x0;
$a->x0->y0 = 'b';
var_dump($a);
?>

Expected result:
----------------
object(stdClass)#1 (1) {
  ["x0"]=>
  &object(stdClass)#2 (3) {
    ["y0"]=>
    string(1) "b"
    ["y1"]=>
    &object(stdClass)#2 (3) {
      ["y0"]=>
      string(1) "b"
      ["y1"]=>
      *RECURSION*
      ["y2"]=>
      *RECURSION*
    }
    ["y2"]=>
    &object(stdClass)#2 (3) {
      ["y0"]=>
      string(1) "b"
      ["y1"]=>
      *RECURSION*
      ["y2"]=>
      *RECURSION*
    }
  }
}


Actual result:
--------------
object(stdClass)#1 (1) {
  ["x0"]=>
  object(stdClass)#2 (3) {
    ["y0"]=>
    string(1) "b"
    ["y1"]=>
    object(stdClass)#2 (3) {
      ["y0"]=>
      string(1) "b"
      ["y1"]=>
      *RECURSION*
      ["y2"]=>
      *RECURSION*
    }
    ["y2"]=>
    object(stdClass)#2 (3) {
      ["y0"]=>
      string(1) "b"
      ["y1"]=>
      *RECURSION*
      ["y2"]=>
      *RECURSION*
    }
  }
}
/home/dmitry/php/php5.1/Zend/zend_vm_execute.h(393) :  Freeing 0x08B29C94 (16 bytes), script=ass4.php
=== Total 1 memory leaks detected ===


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-16 13:28 UTC] dmitry@php.net
Fixed in CVS HEAD, PHP_5_1 and PHP_5_0.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jan 31 05:01:30 2025 UTC