[php-src] Issue #14343: Memory leak in xml and dom
| From: | YuanchengJiang | Date: | Tue, 28 May 2024 06:44:46 +0000 |
| Subject: | [php-src] Issue #14343: Memory leak in xml and dom | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246974@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/14343
Author: YuanchengJiang
### Description
The following code:
```php
<?php
$aDOM = new DOMDocument();
$fromdom = new DOMDocument();
$fromdom->loadXML('<data xmlns:ai="http://test.org" ai:attr="namespaced" />');
$attr= $fromdom->firstChild->attributes->item(0);
$att = $aDOM->importNode($attr);
?>
```
Resulted in this output:
```
=================================================================
==1967160==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 48 byte(s) in 1 object(s) allocated from:
#0 0x55568de88c0e in malloc (/usr/local/bin/php+0x1c88c0e) (BuildId:
c0213df21908f588a04dfadca2142af951d35e31)
#1 0x7fe0647a6b0d in xmlNewNs (/lib/x86_64-linux-gnu/libxml2.so.2+0x61b0d) (BuildId:
aebf8e42966c3ce475ff9d9d51a762831adcbb61)
Indirect leak of 19 byte(s) in 2 object(s) allocated from:
#0 0x55568de88c0e in malloc (/usr/local/bin/php+0x1c88c0e) (BuildId:
c0213df21908f588a04dfadca2142af951d35e31)
#1 0x7fe0648287f2 in xmlStrdup (/lib/x86_64-linux-gnu/libxml2.so.2+0xe37f2) (BuildId:
aebf8e42966c3ce475ff9d9d51a762831adcbb61)
```
### PHP Version
nightly
### Operating System
ubuntu 22.04