xref: /php-src/ext/xml/tests/bug81481.phpt (revision b41e90c6)
1--TEST--
2Bug #81481 (xml_get_current_byte_index limited to 32-bit numbers on 64-bit builds)
3--CREDITS--
4dev at b65sol dot com
5--EXTENSIONS--
6xml
7--INI--
8memory_limit=-1
9--SKIPIF--
10<?php
11require __DIR__ . '/libxml_expat_skipif.inc';
12skipif(want_expat: false);
13if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
14if (PHP_INT_SIZE != 8) die("skip 64-bit only");
15if (PHP_OS_FAMILY == 'Windows') die('skip not for Windows');
16?>
17--FILE--
18<?php
19$parser = xml_parser_create('UTF-8');
20xml_set_element_handler( $parser, 'startelement', null );
21
22$emptylong = str_repeat(' ', 1024*1024);
23xml_parse($parser, '<root><i></i><b/><ext>Hello</ext>', false);
24for($i = 0; $i < 2200; $i++) {
25    xml_parse($parser, $emptylong, false);
26}
27xml_parse($parser, '<ext></ext><ext></ext></root>', false);
28
29function startelement($parser, $name, $attribute) {
30    if ( $name == 'EXT' ) { echo "Byte Index:", xml_get_current_byte_index($parser), "\n"; }
31}
32?>
33--EXPECT--
34Byte Index:21
35Byte Index:2306867237
36Byte Index:2306867248
37