php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24222 crash: setting parent reference to child, then do for/count empty loop
Submitted: 2003-06-17 07:15 UTC Modified: 2003-06-17 11:20 UTC
From: xuefer at 21cn dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.3.2 OS: win32
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: xuefer at 21cn dot com
New email:
PHP Version: OS:

 

 [2003-06-17 07:15 UTC] xuefer at 21cn dot com
Description:
------------
crash in page 2nd time loading
let the code say everything

Reproduce code:
---------------
$match = array( 0 => array("1", "2", "3", "4", "5"));
$match = &$match[0];
for ($i = 0, $c = count($match); $i < $c; $i ++) {
  // empty loop
}

however, the following code will not crash:
$match = array( 0 => array("1", "2", "3", "4", "5"));
$match = &$match[0];
echo $c = count($match);
for ($i = 0, $c = count($match); $i < $c; $i ++) {
  // empty loop
}

Expected result:
----------------
should not crash

Actual result:
--------------
but it did crash :(

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-17 07:20 UTC] xuefer at 21cn dot com
(summary typo fix)
bye the way,
the work arround is to change code into:
$match = array( 0 => array("1", "2", "3", "4", "5"));
$m = &$match[0];
for ($i = 0, $c = count($m); $i < $c; $i ++) {
  // now, we can do our work
}
 [2003-06-17 11:20 UTC] sniper@php.net
Latest CVS does not crash.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Mar 15 15:01:29 2025 UTC