Skip to content

Commit 4bc797f

Browse files
committed
Add tests for bugs #72793 and bugs #76874
These leaks have been resolved by the introduction of a proper get_gc() implementation.
1 parent d853f91 commit 4bc797f

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

ext/xml/tests/bug72793.phpt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Bug #72793: xml_parser_free leaks mem when execute xml_set_object
3+
--FILE--
4+
<?php
5+
6+
class xml {
7+
var $parser;
8+
9+
function __construct()
10+
{
11+
$this->parser = xml_parser_create();
12+
xml_set_object($this->parser, $this);
13+
}
14+
15+
function parse($data)
16+
{
17+
xml_parse($this->parser, $data);
18+
}
19+
20+
function free(){
21+
xml_parser_free($this->parser);
22+
}
23+
}
24+
25+
$xml_test = '<?xml version="1.0" encoding="utf-8"?><test></test>';
26+
$xml_parser = new xml();
27+
$xml_parser->parse($xml_test);
28+
$xml_parser->free();
29+
30+
?>
31+
===DONE===
32+
--EXPECT--
33+
===DONE===

ext/xml/tests/bug76874.phpt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Bug #76874: xml_parser_free() should never leak memory
3+
--FILE--
4+
<?php
5+
6+
class c
7+
{
8+
private $xml;
9+
private $test;
10+
11+
public function test()
12+
{
13+
$this->xml = xml_parser_create();
14+
xml_set_character_data_handler($this->xml, array(&$this, 'handle_cdata'));
15+
xml_parser_free($this->xml);
16+
}
17+
18+
public function handle_cdata(&$parser, $data)
19+
{
20+
}
21+
}
22+
23+
$object = new c();
24+
$object->test();
25+
26+
?>
27+
===DONE===
28+
--EXPECT--
29+
===DONE===

0 commit comments

Comments
 (0)