xref: /php-src/ext/xml/tests/gh14124.phpt (revision 234b3cb2)
1--TEST--
2GH-14124 (Segmentation fault on unknown address 0x0001ffff8041 with XML extension under certain memory limit)
3--EXTENSIONS--
4xml
5--INI--
6memory_limit=33M
7--SKIPIF--
8<?php
9if (!defined("LIBXML_VERSION")) die('skip this is a libxml2 test');
10if (getenv('SKIP_ASAN')) die('xleak libxml does not use the request allocator');
11?>
12--FILE--
13<?php
14function createParser(bool $huge) {
15    $parser = xml_parser_create();
16    xml_parser_set_option($parser, XML_OPTION_PARSE_HUGE, $huge);
17    return $parser;
18}
19
20$long_text = str_repeat("A", 1000 * 1000 * 5 /* 5 MB */);
21$long_xml_head = "<?xml version=\"1.0\"?><container><$long_text/><$long_text/><second>foo</second>";
22$long_xml_tail = "</container>";
23$parser = createParser(true);
24xml_parse_into_struct($parser, $long_xml_head . $long_xml_tail, $values, $index);
25?>
26--EXPECTF--
27Fatal error: Allowed memory size of %d bytes exhausted %s in %s on line %d
28