php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46110 XMLWriter - openmemory() and openuri() mem. leaks
Submitted: 2008-09-17 18:07 UTC Modified: 2008-09-17 23:28 UTC
From: felipe@php.net Assigned:
Status: Closed Package: XML Writer
PHP Version: 5.3CVS-2008-09-17 (CVS) OS:
Private report: No CVE-ID: None
 [2008-09-17 18:07 UTC] felipe@php.net
Description:
------------
The mem. leak happens when calling two or more times the openuri() and openmemory(). See below.

Reproduce code:
---------------
<?php

$x = new xmlwriter;
$x->openuri(1);
$x->openuri(1);

$x->openmemory();
$x->openmemory();

Actual result:
--------------
==19574== 18 bytes in 6 blocks are indirectly lost in loss record 2 of 14
==19574==    at 0x4021620: malloc (vg_replace_malloc.c:149)
==19574==    by 0x51CFE65: xmlStrndup (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x51D000B: xmlStrdup (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x5225BE9: xmlNewTextWriter (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x52260D1: xmlNewTextWriterFilename (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x8357E54: zif_xmlwriter_open_uri (php_xmlwriter.c:1833)
==19574==    by 0x83FB4DF: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:315)
==19574==    by 0x83E9602: execute (zend_vm_execute.h:104)
==19574==    by 0x83C3A6E: zend_execute_scripts (zend.c:1197)
==19574==    by 0x836916C: php_execute_script (main.c:2080)
==19574==    by 0x845B734: main (php_cli.c:1130)
==19574== 
==19574== 8,450 (8 direct, 8,442 indirect) bytes in 1 blocks are definitely lost in loss record 12 of 14
==19574==    at 0x4021620: malloc (vg_replace_malloc.c:149)
==19574==    by 0x8357C71: zif_xmlwriter_open_memory (php_xmlwriter.c:1890)
==19574==    by 0x83FB4DF: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:315)
==19574==    by 0x83E9602: execute (zend_vm_execute.h:104)
==19574==    by 0x83C3A6E: zend_execute_scripts (zend.c:1197)
==19574== 64 bytes in 4 blocks are indirectly lost in loss record 5 of 14
==19574==    at 0x4021620: malloc (vg_replace_malloc.c:149)
==19574==    by 0x517C151: xmlBufferCreate (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x5185786: xmlAllocOutputBuffer (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x518585A: xmlOutputBufferCreateIO (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x51858BB: xmlOutputBufferCreateBuffer (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x522602C: xmlNewTextWriterMemory (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x8357C5F: zif_xmlwriter_open_memory (php_xmlwriter.c:1884)
==19574==    by 0x83FB4DF: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:315)
==19574==    by 0x83E9602: execute (zend_vm_execute.h:104)
==19574==    by 0x83C3A6E: zend_execute_scripts (zend.c:1197)
==19574==    by 0x836916C: php_execute_script (main.c:2080)
==19574==    by 0x845B734: main (php_cli.c:1130)
==19574== 
==19574== 
==19574== 72 bytes in 6 blocks are indirectly lost in loss record 6 of 14
==19574==    at 0x4021620: malloc (vg_replace_malloc.c:149)
==19574==    by 0x5184C0B: xmlListCreate (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x5225BB0: xmlNewTextWriter (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x522603A: xmlNewTextWriterMemory (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x8357C5F: zif_xmlwriter_open_memory (php_xmlwriter.c:1884)
==19574==    by 0x83FB4DF: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:315)
==19574==    by 0x83E9602: execute (zend_vm_execute.h:104)
==19574==    by 0x83C3A6E: zend_execute_scripts (zend.c:1197)
==19574==    by 0x836916C: php_execute_script (main.c:2080)
==19574==    by 0x845B734: main (php_cli.c:1130)
==19574== 
==19574== 
==19574== 72 bytes in 6 blocks are indirectly lost in loss record 7 of 14
==19574==    at 0x4021620: malloc (vg_replace_malloc.c:149)
==19574==    by 0x5184BE8: xmlListCreate (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x5225BB0: xmlNewTextWriter (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x52260D1: xmlNewTextWriterFilename (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x8357E54: zif_xmlwriter_open_uri (php_xmlwriter.c:1833)
==19574==    by 0x83FB4DF: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:315)
==19574==    by 0x83E9602: execute (zend_vm_execute.h:104)
==19574==    by 0x83C3A6E: zend_execute_scripts (zend.c:1197)
==19574==    by 0x836916C: php_execute_script (main.c:2080)
==19574==    by 0x845B734: main (php_cli.c:1130)
==19574== 
==19574== 
==19574== 96 bytes in 3 blocks are indirectly lost in loss record 8 of 14
==19574==    at 0x4021620: malloc (vg_replace_malloc.c:149)
==19574==    by 0x5185768: xmlAllocOutputBuffer (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x8072B24: php_libxml_output_buffer_create_filename (libxml.c:413)
==19574==    by 0x518848F: xmlOutputBufferCreateFilename (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x52260C3: xmlNewTextWriterFilename (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x8357E54: zif_xmlwriter_open_uri (php_xmlwriter.c:1833)
==19574==    by 0x83FB4DF: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:315)
==19574==    by 0x83E9602: execute (zend_vm_execute.h:104)
==19574==    by 0x83C3A6E: zend_execute_scripts (zend.c:1197)
==19574==    by 0x836916C: php_execute_script (main.c:2080)
==19574==    by 0x845B734: main (php_cli.c:1130)
==19574== 
==19574== 
==19574== 132 bytes in 3 blocks are indirectly lost in loss record 9 of 14
==19574==    at 0x4021620: malloc (vg_replace_malloc.c:149)
==19574==    by 0x5225B82: xmlNewTextWriter (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x522603A: xmlNewTextWriterMemory (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x8357C5F: zif_xmlwriter_open_memory (php_xmlwriter.c:1884)
==19574==    by 0x83FB4DF: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:315)
==19574==    by 0x83E9602: execute (zend_vm_execute.h:104)
==19574==    by 0x83C3A6E: zend_execute_scripts (zend.c:1197)
==19574==    by 0x836916C: php_execute_script (main.c:2080)
==19574==    by 0x845B734: main (php_cli.c:1130)
==19574== 
==19574== 
==19574== 264 bytes in 3 blocks are indirectly lost in loss record 10 of 14
==19574==    at 0x4021620: malloc (vg_replace_malloc.c:149)
==19574==    by 0x517D843: xmlNewDoc (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x5225C00: xmlNewTextWriter (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x522603A: xmlNewTextWriterMemory (in /usr/lib/libxml2.so.2.6.27)
==19574==    by 0x8357C5F: zif_xmlwriter_open_memory (php_xmlwriter.c:1884)
==19574==    by 0x83FB4DF: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:315)
==19574==    by 0x83E9602: execute (zend_vm_execute.h:104)
==19574==    by 0x83C3A6E: zend_execute_scripts (zend.c:1197)
==19574==    by 0x836916C: php_execute_script (main.c:2080)
==19574==    by 0x845B734: main (php_cli.c:1130)
==19574== 
==19574== 
==19574==    by 0x836916C: php_execute_script (main.c:2080)
==19574==    by 0x845B734: main (php_cli.c:1130)
==19574== 
==19574== 
==19574== 8,676 (16 direct, 8,660 indirect) bytes in 2 blocks are definitely lost in loss record 13 of 14
==19574==    at 0x4021620: malloc (vg_replace_malloc.c:149)
==19574==    by 0x8357E6A: zif_xmlwriter_open_uri (php_xmlwriter.c:1840)
==19574==    by 0x83FB4DF: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:315)
==19574==    by 0x83E9602: execute (zend_vm_execute.h:104)
==19574==    by 0x83C3A6E: zend_execute_scripts (zend.c:1197)
==19574==    by 0x836916C: php_execute_script (main.c:2080)
==19574==    by 0x845B734: main (php_cli.c:1130)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-17 23:28 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 10:01:29 2024 UTC