xref: /PHP-8.2/ext/xml/tests/gh12254.phpt (revision 30f26b58)
1--TEST--
2GH-12254: xml_parse_into_struct() memory leak when called twice
3--EXTENSIONS--
4xml
5--FILE--
6<?php
7
8$parser = xml_parser_create();
9xml_set_element_handler($parser, function ($parser, $name, $attrs) {
10    echo "open\n";
11    var_dump($name, $attrs);
12    var_dump(xml_parse_into_struct($parser, "<container/>", $values, $tags));
13}, function ($parser, $name) {
14    echo "close\n";
15    var_dump($name);
16});
17xml_parse_into_struct($parser, "<container/>", $values, $tags);
18// Yes, this doesn't do anything but it at least shouldn't leak...
19xml_parse_into_struct($parser, "<container/>", $values, $tags);
20
21?>
22--EXPECTF--
23open
24string(9) "CONTAINER"
25array(0) {
26}
27
28Warning: xml_parse_into_struct(): Parser must not be called recursively in %s on line %d
29bool(false)
30close
31string(9) "CONTAINER"
32