php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27481 double references corrupts variables
Submitted: 2004-03-03 08:16 UTC Modified: 2004-03-04 13:36 UTC
From: juergen at henge-ernst dot de Assigned: andi (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 4.3.5RC3 OS: linux
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: juergen at henge-ernst dot de
New email:
PHP Version: OS:

 

 [2004-03-03 08:16 UTC] juergen at henge-ernst dot de
Description:
------------
I tried the following with the lastest snapshot 
php4-STABLE-200403031030/sapi/cli/php
just did a ./configure without an options 

when using double references (accidently or not) the variables in PHP get corrupted.
$acl contains the content of $y

If you change the line
$y = 'TestString';
to
#$y = 'TestString';
or add an var_dump($acl) before that line
everything works as expected (including the call to the undefined function of that object). It looks like an internal pointer is not reseted correctly

previous version sometimes crashed wich seems no longer to be the case.



Reproduce code:
---------------
class TestObj {
    var $x;
    function &save() {
        return $this;
    }
}
$acl = new TestObj();
$acl = &$acl->save();
$y = 'TestString';
var_dump($acl);
if (is_object($acl)) {
    $acl->dump();
}


Expected result:
----------------
object(testobj)(0) {
}


Actual result:
--------------
string(10) "TestString"


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-03 08:22 UTC] derick@php.net
Verified, but works in PHP 5.0dev (and beta4).
 [2004-03-04 13:36 UTC] andi@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 27 00:00:03 2025 UTC