|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40752 parse_ini_file() segfaults when a scalar setting is redeclared as an array
Submitted: 2007-03-08 00:13 UTC Modified: 2007-03-08 00:43 UTC
From: hubert dot roksor at gmail dot com Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 5.2.1 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: hubert dot roksor at gmail dot com
New email:
PHP Version: OS:


 [2007-03-08 00:13 UTC] hubert dot roksor at gmail dot com
Using [] in a key name can result in a crash if the corresponding setting was previously set to a scalar value.

Reproduce code:
// Not relevant to the bug
$file = tempnam('./', '');
file_put_contents($file, '
foo  =1;

// Will make PHP crash

Expected result:
In the attached reproduce code we create a ini file which has 2 keys, "foo" and "foo[]" then we execute parse_ini_file() on the newly-created file.

Because "Characters {}|&~![()" must not be used anywhere in the key" (dixit the manual) I'd expect an error message, or at least a Strict notice.

Actual result:
PHP segfaults/crashes

(tested on 5.2.1 on WinXP and 5.1.2 on Ubuntu 6.06)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-08 00:43 UTC]
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
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Feb 01 05:03:45 2023 UTC