Skip to content

Segmentation fault (access null pointer) in ext/libxml/libxml.c #14698

Closed
@YuanchengJiang

Description

@YuanchengJiang

Description

The following code:

<?php
  $dom = new DOMDocument;
  $dom->loadHTML('<span title=""y">x</span><span title=""z">x</span>');
  $html = simplexml_import_dom($dom);
  foreach ($html->body->span as $obj) {
  }
  $script1_dataflow = $html;
  $array = ['foo'];
  foreach ($array as $key => &$value) {
    unset($script1_dataflow[$key]);
  }

Resulted in this output:

Segmentation fault (core dumped)

UBSan:

/php-src/ext/libxml/libxml.c:333:16: runtime error: member access within null pointer of type 'php_libxml_node_object' (aka 'struct _php_libxml_node_object')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /php-src/ext/libxml/libxml.c:333:16

PHP Version

PHP 8.4.0-dev

Operating System

ubuntu 22.04

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions