Bug #80602 [Opn->Ver]: Segfault when using DOMChildNode::before()
| From: | nikic@php.net | Date: | Wed, 06 Jan 2021 20:45:52 +0000 |
| Subject: | Bug #80602 [Opn->Ver]: Segfault when using DOMChildNode::before() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-231421@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80602&edit=1
ID: 80602
Updated by: nikic@php.net
Reported by: jules dot bernable at gmail dot com
Summary: Segfault when using DOMChildNode::before()
-Status: Open
+Status: Verified
Type: Bug
Package: DOM XML related
Operating System: debian
PHP Version: 8.0.0
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2021-01-06 20:34:13] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80602&edit=1