php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7061 assigning a reference to a member of string
Submitted: 2000-10-06 23:36 UTC Modified: 2000-10-13 23:36 UTC
From: panu dot kalliokoski at giro dot fi Assigned:
Status: Closed Package: Reproducible Crash
PHP Version: 4.0 Latest CVS (06/10/2000) OS: Debian GNU/Linux stable
Private report: No CVE-ID: None
 [2000-10-06 23:36 UTC] panu dot kalliokoski at giro dot fi
This has also been tested with php-4.0.2.

The simplest script I could come up with to produce the core dump is like this:

$a = 'string';
$str = 'another one';
$a[0] =& $str;

This will cause a core dump.

String indexing, IMO, is a misfeature only causing harm. What I find especially irritating is that if I index a string by string index, by accident, it automagically casts the string index to a numeric one. None of my business, of course.

Panu Kalliokoski


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-10-06 13:39 UTC] andi@php.net
Thanks, I just fixed this in the latest CVS. It bails out with an error.
I agree with you about string indexing which is mixed with array offsets syntax being a misfeature. It is due to backwards comaptibility. I have on my TODO list to add a new syntax for string indexing in order to split up these two. But we will need to anyway keep the current behavior because too many scripts in the world rely on it.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Mar 15 11:01:29 2025 UTC