| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 Patchesyaml.array-key.patch (last revision 2013-04-23 00:01 UTC by me at fixxxer dot me)Pull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2013-11-16 22:13 UTC] bd808@php.net
 
-Summary:     segfault on malformed yaml
+Summary:     segfault when array used as mapping key
-Assigned To:
+Assigned To: bd808
  [2013-11-16 22:13 UTC] bd808@php.net
  [2013-11-17 00:43 UTC] bd808@php.net
 
-Status: Assigned
+Status: Closed
  [2013-11-17 00:43 UTC] bd808@php.net
  [2013-11-19 05:47 UTC] bd808@php.net
  | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 05:00:01 2025 UTC | 
Description: ------------ 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: --------------- <?php dl('yaml.so'); $yaml=<<<E [a]: 1 E; yaml_parse($yaml); Actual result: -------------- Program received signal SIGSEGV, Segmentation fault. 0x00007ffff63812a5 in handle_mapping (state=0x7fffffffa7a0) at /home/build/pkgbuild/php54/php-5.4.13/php-build-stamp-cli/yaml/parse.c:432 432 if (IS_NOT_QUOTED_OR_TAG_IS(key_event, YAML_MERGE_TAG) &&