Files
Marc Bennewitz 5ec9164e59 Fix Bug-81481 XML_GetCurrentByteIndex() truncation on Windows x64
The fix for https://bugs.php.net/bug.php?id=81481 made the libxml
compatibility wrapper return long, which is still 32-bit on Windows x64,
so byte indexes beyond 2 GiB turned negative there. Return zend_long
instead and run the test on Windows too.

Closes GH-23901.
2026-10-05 19:42:59 +02:00

37 lines
1011 B
PHP

--TEST--
Bug #81481 (xml_get_current_byte_index limited to 32-bit numbers on 64-bit builds)
--CREDITS--
dev at b65sol dot com
--EXTENSIONS--
xml
--INI--
memory_limit=-1
--SKIPIF--
<?php
if (!getenv('RUN_RESOURCE_HEAVY_TESTS')) die('skip resource-heavy test');
require __DIR__ . '/libxml_expat_skipif.inc';
skipif(want_expat: false);
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
if (PHP_INT_SIZE != 8) die("skip 64-bit only");
?>
--FILE--
<?php
$parser = xml_parser_create('UTF-8');
xml_set_element_handler( $parser, 'startelement', null );
$emptylong = str_repeat(' ', 1024*1024);
xml_parse($parser, '<root><i></i><b/><ext>Hello</ext>', false);
for($i = 0; $i < 2200; $i++) {
xml_parse($parser, $emptylong, false);
}
xml_parse($parser, '<ext></ext><ext></ext></root>', false);
function startelement($parser, $name, $attribute) {
if ( $name == 'EXT' ) { echo "Byte Index:", xml_get_current_byte_index($parser), "\n"; }
}
?>
--EXPECT--
Byte Index:21
Byte Index:2306867237
Byte Index:2306867248