php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23524 Improper handling of constants in array indeces.
Submitted: 2003-05-07 04:03 UTC Modified: 2003-06-10 19:17 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: d dot stogov at turck dot spb dot ru Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.3.2-RC3-dev OS: Any
Private report: No CVE-ID: None
 [2003-05-07 04:03 UTC] d dot stogov at turck dot spb dot ru
This bug exists in PHP version 4.1.2 - 4.3.1 and 5.0.0-dev.
It is similar to bug #18872 (Improper handling of class constants used as default function argument values).

See the following PHP code:

<?php
  function f($a=array(PHP_VERSION=>PHP_VERSION)) {
    print_r($a);
    echo "<br>\n";
  }
  f();
  f();
?>

The function "f" should print the same result at first and at second invocation but it is not true. The output is:

Array
(
    [4.3.1] => 4.3.1
)
<br>
Array
(
    [PHP_VERSION] => 4.3.1
)
<br>

The error is in handling of "ZEND_RECV_INIT" opcode and in
function "zval_update_constant" that resets "IS_CONSTANT_INDEX" flag in original "zval" instead of copy.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-10 19:17 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Dec 18 09:00:01 2025 UTC