Skip to content

Memory leak in xml and dom #14343

Description

@YuanchengJiang

Description

The following code:

<?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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions