[php-src] Issue #19956: memory leak xmlCopyDocElementContent

From: Date: Thu, 25 Sep 2025 06:17:07 +0000
Subject: [php-src] Issue #19956: memory leak xmlCopyDocElementContent
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-250915@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/19956 Author: YuanchengJiang ### Description The following code: ```php <?php $xml = "<?xml version=\"1.0\"?> <!DOCTYPE note [ <!ELEMENT note (to,from,heading,body)> ]> <note> </note>"; $dom = new DOMDocument('1.0'); $dom->loadXML($xml); $dom2 = clone $dom; ``` Resulted in this output: ``` ================================================================= ==2468545==ERROR: LeakSanitizer: detected memory leaks Direct leak of 48 byte(s) in 1 object(s) allocated from: #0 0x6810bd in malloc (/home/phpfuzz/WorkSpace/flowfusion/php-src/sapi/cli/php+0x6810bd) #1 0x7483cebbe752 in xmlCopyDocElementContent (/lib/x86_64-linux-gnu/libxml2.so.2+0x85752) Indirect leak of 96 byte(s) in 2 object(s) allocated from: #0 0x6810bd in malloc (/home/phpfuzz/WorkSpace/flowfusion/php-src/sapi/cli/php+0x6810bd) #1 0x7483cebbe752 in xmlCopyDocElementContent (/lib/x86_64-linux-gnu/libxml2.so.2+0x85752) Indirect leak of 48 byte(s) in 1 object(s) allocated from: #0 0x6810bd in malloc (/home/phpfuzz/WorkSpace/flowfusion/php-src/sapi/cli/php+0x6810bd) #1 0x7483cebbe6ac in xmlCopyDocElementContent (/lib/x86_64-linux-gnu/libxml2.so.2+0x856ac) Indirect leak of 13 byte(s) in 2 object(s) allocated from: #0 0x6810bd in malloc (/home/phpfuzz/WorkSpace/flowfusion/php-src/sapi/cli/php+0x6810bd) #1 0x7483cec1c7c2 in xmlStrdup (/lib/x86_64-linux-gnu/libxml2.so.2+0xe37c2) SUMMARY: AddressSanitizer: 205 byte(s) leaked in 6 allocation(s). ``` To reproduce: ``` ./php-src/sapi/cli/php ./test.php ``` Commit: ``` e23c6222da50a2c5828a03ad701cd3351b13590d ``` Configurations: ``` CC="clang-12" CXX="clang++-12" CFLAGS="-DZEND_VERIFY_TYPE_INFERENCE" CXXFLAGS="-DZEND_VERIFY_TYPE_INFERENCE" ./configure --enable-debug --enable-address-sanitizer --enable-undefined-sanitizer --enable-re2c-cgoto --enable-fpm --enable-litespeed --enable-phpdbg-debug --enable-zts --enable-bcmath --enable-calendar --enable-dba --enable-dl-test --enable-exif --enable-ftp --enable-gd --enable-gd-jis-conv --enable-mbstring --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-zend-test --with-zlib --with-bz2 --with-curl --with-enchant --with-gettext --with-gmp --with-mhash --with-ldap --with-libedit --with-readline --with-snmp --with-sodium --with-xsl --with-zip --with-mysqli --with-pdo-mysql --with-pdo-pgsql --with-pgsql --with-sqlite3 --with-pdo-sqlite --with-webp --with-jpeg --with-freetype --enable-sigchild --with-readline --with-pcre-jit --with-iconv ``` Operating System: ``` Ubuntu 20.04 Host, Docker 0599jiangyc/flowfusion:latest ``` *This report is automatically generated by [FlowFusion](https://github.com/php/flowfusion)* ### PHP Version ```plain nightly ``` ### Operating System _No response_

« previous php.bugs (#250915) next »