[php-src] Issue #16039: Segmentation fault (access null pointer) in ext/dom/parentnode/tree.c
| From: | YuanchengJiang | Date: | Wed, 25 Sep 2024 04:46:43 +0000 |
| Subject: | [php-src] Issue #16039: Segmentation fault (access null pointer) in ext/dom/parentnode/tree.c | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-247892@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/16039
Author: YuanchengJiang
### Description
The following code:
```php
<?php
$entity = new DOMEntity();
$fusion = $entity;
$dom = new DOMDocument;
$element = $dom->appendChild($dom->createElement('root'));
$str = str_repeat('X', 2**31 + 10);
try {
$element->append('x', $str);
} catch (ValueError $e) {
$element->prepend('x', $fusion);
}
```
Resulted in this output:
```
/php-src/ext/dom/parentnode/tree.c:245:12: runtime error: member access within null pointer of type
'xmlNode' (aka 'struct _xmlNode')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /php-src/ext/dom/parentnode/tree.c:245
```
To reproduce:
```
-d "memory_limit=-1"
```
### PHP Version
PHP 8.4.0-dev
### Operating System
ubuntu 22.04