|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2021-01-06 20:34 UTC] jules dot bernable at gmail dot com
Description:
------------
When calling DOMChildNode::before() on an element, if one of the parameters is a text node that is the previous sibling of that element, the program segfaults.
Test script:
---------------
<?php declare(strict_types=1);
$doc = new \DOMDocument();
$doc->loadXML('<a>foo<last/></a>');
$target = $doc->documentElement->lastChild;
$target->before('bar', $doc->documentElement->firstChild, 'baz');
echo $doc->saveXML($doc->documentElement);
Expected result:
----------------
<a>barfoobaz<last/></a>
Actual result:
--------------
free(): double free detected in tcache 2
Aborted
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 03:00:02 2025 UTC |
Confusingly, it segfaults with $target->before('bar', $doc->documentElement->firstChild, 'baz'); but it works with $target->before($doc->documentElement->firstChild, 'baz'); or even $target->before($doc->documentElement->firstChild);