|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64694 segfault when array used as mapping key
Submitted: 2013-04-23 00:01 UTC Modified: 2013-11-17 00:43 UTC
From: me at fixxxer dot me Assigned: bd808 (profile)
Status: Closed Package: yaml (PECL)
PHP Version: 5.4Git-2013-04-22 (snap) OS: any
Private report: No CVE-ID: None
 [2013-04-23 00:01 UTC] me at fixxxer dot me
Pecl/yaml segfaults on malformed yaml with array keys (see the test script).

The patch attached fixes the problem.

The simple fix is to check for null pointer on the SCALAR_TAG_IS macros. But I see 
absolutely no sense in returning serialized data from convert_to_char() which is 
used only for keys. So I've just dropped the serialization block, and handle the 
null return.

Test script:



Actual result:
Program received signal SIGSEGV, Segmentation fault.

0x00007ffff63812a5 in handle_mapping (state=0x7fffffffa7a0) at 

432			if (IS_NOT_QUOTED_OR_TAG_IS(key_event, YAML_MERGE_TAG) && 


yaml.array-key.patch (last revision 2013-04-23 00:01 UTC by me at fixxxer dot me)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-11-16 22:13 UTC]
-Summary: segfault on malformed yaml +Summary: segfault when array used as mapping key -Assigned To: +Assigned To: bd808
 [2013-11-16 22:13 UTC]
Interestingly this is not malformed YAML. According to the YAML 1.1 spec using an array as the key for a mapping value is perfectly legitimate [0].

Obviously causing PHP to segfault is a bug however.

 [2013-11-17 00:43 UTC]
-Status: Assigned +Status: Closed
 [2013-11-17 00:43 UTC]
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

 [2013-11-19 05:47 UTC]
Patch included in 1.1.1 release.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 20 23:01:28 2024 UTC