Skip to content

Unexpected null pointer in zend_string.h #13685

Closed

Description

@YuanchengJiang

Description

The following code:

<?php
$contents = <<<EOS
"cell1","cell2\\","cell3","cell4"
"\\\\\\line1
line2\\\\\\"
EOS;
$file = new SplTempFileObject;
$file->fwrite($contents);
$file->rewind();
while (($data = $file->fgetcsv(',', '"', ''))) {
    print_r($data);
}
$xconnect = $file;
$dom = new DOMDocument;
$dom->loadXML("<root><x/><x xmlns:a=\"urn:a\" xmlns:b=\"urn:b\"/><x xmlns:b=\"urn:b\" xmlns:a=\"urn:a\"/></root>");
foreach ($dom->getElementsByTagName('x') as $x1) {
    foreach ($dom->getElementsByTagName('x') as $x2) {
        echo "Comparing ", $dom->saveXML($x1), " with ", $dom->saveXML($x2), "\n";
        var_dump($x1->isEqualNode($x2));
    }
}
$xconnect = $xconnect.$dom;
eval($xconnect);
?>

See: https://3v4l.org/md1YH

Resulted in this output:

/WorkSpace/php-src/Zend/zend_string.h:200:24: runtime error: null pointer passed as argument 2, which is declared to never be null
/usr/include/string.h:44:28: note: nonnull attribute specified here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /WorkSpace/php-src/Zend/zend_string.h:200:24 in

PHP Version

PHP 8.4.0-dev

Operating System

ubuntu 22.04

Activity

  1. ndossche commented on Mar 12, 2024

    @ndossche
    Member

    This is unrelated to DOM, it's an SPL bug caused by 6fbf81c. Fix incoming soon.

  2. added 2 commits that reference this issue on Mar 17, 2024
    aa34e0a
    dab5f8c
  3. added a commit that references this issue on Mar 17, 2024
    47b6eab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions