[php-src] Issue #20721: xml memory leak

[email protected] (chongwick)
Newsgroups php.bugs
Message-ID <[email protected]>
Issue: https://github.com/php/php-src/issues/20721
Author: chongwick

### Description

The following code:

```php
<?php
$v_847 = STDOUT;
$v_848 = fclose($v_847,);
$v_2964 = new SoapServer($v_848,);
```

Resulted in this output:
```
=================================================================
==2545344==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 343 byte(s) in 1 object(s) allocated from:
    #0 0x6829fd in malloc (/home/w023dtc/nightly_php/php-src/sapi/cli/php+0x6829fd)
    #1 0x14a4a27fe6b3 in xmlStrndup (/lib/x86_64-linux-gnu/libxml2.so.2+0xe36b3)

Indirect leak of 600 byte(s) in 5 object(s) allocated from:
    #0 0x6829fd in malloc (/home/w023dtc/nightly_php/php-src/sapi/cli/php+0x6829fd)
    #1 0x14a4a277d5f4 in xmlNewNode (/lib/x86_64-linux-gnu/libxml2.so.2+0x625f4)

Indirect leak of 176 byte(s) in 1 object(s) allocated from:
    #0 0x6829fd in malloc (/home/w023dtc/nightly_php/php-src/sapi/cli/php+0x6829fd)
    #1 0x14a4a277d217 in xmlNewDoc (/lib/x86_64-linux-gnu/libxml2.so.2+0x62217)

Indirect leak of 121 byte(s) in 6 object(s) allocated from:
    #0 0x6829fd in malloc (/home/w023dtc/nightly_php/php-src/sapi/cli/php+0x6829fd)
    #1 0x14a4a27fe6b3 in xmlStrndup (/lib/x86_64-linux-gnu/libxml2.so.2+0xe36b3)

Indirect leak of 120 byte(s) in 1 object(s) allocated from:
    #0 0x6829fd in malloc (/home/w023dtc/nightly_php/php-src/sapi/cli/php+0x6829fd)
    #1 0x14a4a277d87b in xmlNewText (/lib/x86_64-linux-gnu/libxml2.so.2+0x6287b)

Indirect leak of 120 byte(s) in 1 object(s) allocated from:
    #0 0x6829fd in malloc (/home/w023dtc/nightly_php/php-src/sapi/cli/php+0x6829fd)
    #1 0x14a4a277e9eb in xmlNewTextLen (/lib/x86_64-linux-gnu/libxml2.so.2+0x639eb)

Indirect leak of 63 byte(s) in 3 object(s) allocated from:
    #0 0x6829fd in malloc (/home/w023dtc/nightly_php/php-src/sapi/cli/php+0x6829fd)
    #1 0x14a4a27fe7c2 in xmlStrdup (/lib/x86_64-linux-gnu/libxml2.so.2+0xe37c2)

Indirect leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x6829fd in malloc (/home/w023dtc/nightly_php/php-src/sapi/cli/php+0x6829fd)
    #1 0x14a4a277cb0d in xmlNewNs (/lib/x86_64-linux-gnu/libxml2.so.2+0x61b0d)

Indirect leak of 6 byte(s) in 1 object(s) allocated from:
    #0 0x6829fd in malloc (/home/w023dtc/nightly_php/php-src/sapi/cli/php+0x6829fd)
    #1 0x14a4a27fe962 in xmlCharStrdup (/lib/x86_64-linux-gnu/libxml2.so.2+0xe3962)

Indirect leak of 5 byte(s) in 1 object(s) allocated from:
    #0 0x6829fd in malloc (/home/w023dtc/nightly_php/php-src/sapi/cli/php+0x6829fd)
    #1 0x14a4a280142b in xmlBufResize (/lib/x86_64-linux-gnu/libxml2.so.2+0xe642b)

SUMMARY: AddressSanitizer: 1602 byte(s) leaked in 21 allocation(s).
```



### PHP Version

```plain
nightly
```

### Operating System

ubuntu 22.04
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.