Skip to content

DOM memory leak #17145

Closed
Closed

Description

@YuanchengJiang

Description

The following code:

<?php
$element = new DOMElement("N", "W", "y");
$attr = new DOMAttr("c" , "n");
$doc = new DOMDocument();
$doc->appendChild($element);
$element->setAttributeNodeNS($attr);
$attr->appendChild($doc->createEntityReference('amp'));
var_dump(get_defined_vars());

Resulted in this output:

==423827==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 6 byte(s) in 3 object(s) allocated from:
    #0 0x6807fd in malloc (/home/phpfuzz/WorkSpace/flowfusion/php-src/sapi/cli/php+0x6807fd)
    #1 0x7f5aae2356e3 in xmlStrndup (/lib/x86_64-linux-gnu/libxml2.so.2+0xe36e3)

SUMMARY: AddressSanitizer: 6 byte(s) leaked in 3 allocation(s).

PHP Version

nightly

Operating System

ubuntu 22.04

Activity

  1. devnexen commented on Dec 13, 2024

    @devnexen
    Member

    might be a libxml2 version issue ? cc @nielsdos

  2. ndossche commented on Dec 13, 2024

    @ndossche
    Member

    might be a libxml2 version issue ? cc @nielsdos

    Good guess, but for once this is caused by an issue in PHP, it's a stupid typo in this case.

  3. linked a pull request that will close this issueFix GH-17145: DOM memory leak #17147on Dec 13, 2024
  4. added a commit that references this issue on Dec 13, 2024
    29fcf12
  5. added 2 commits that reference this issue on Dec 14, 2024
    c015242
    4656c22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions