php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7258 Dangling references destroy session state
Submitted: 2000-10-16 16:08 UTC Modified: 2000-11-01 02:28 UTC
From: sd at b-comp dot de Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.3pl1 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: sd at b-comp dot de
New email:
PHP Version: OS:

 

 [2000-10-16 16:08 UTC] sd at b-comp dot de
(The problem described is specific to 4.0.3 and 4.0.3pl1.
The scripts below work fine with 4.0.2.)

Let $a be an array kept in the session state.  Whenever
a reference $x to an element of $a falls of the end of a
script, the referenced array element is destroyed.
Putting an ``undef($x);'' at the end of the script solves
the problem.  The following two scripts demonstate the
problem:

BEGIN FILE test1.php
<?php
  session_register('a');
  $a = array();
  $a['foo'] = 'FOO';
?>
<html>
<a href="test2.php?<?=SID?>">link</a>
</html>
END FILE

BEGIN FILE test2.php
<?php
  session_register('a');
  $x = &$a['foo'];
?>
<html>
x=<?=$x?><br>
<a href="test2.php?<?=SID?>">link</a>
</html>
END FILE

Open test1.php in a browser and follow the link to
test2.php.  You'll see that $x is 'FOO'.  Now follow
that link again and $x is undefined.

The scripts work if you put an ``undef($x);'' at the
end of test2.php.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-10-23 05:03 UTC] stas@php.net
Please check current CVS, it should be fixed
 [2000-11-01 02:28 UTC] andi@php.net
No feedback from user for quite some time. Assume it works for him.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sat Oct 10 16:00:02 2026 UTC