GNOME Bugzilla – Bug 767138
xmlGetLineNo() reports inaccurately line numbers >= 65535
Last modified: 2021-07-05 13:25:09 UTC
xmlGetLineNo() returns invalid value in certain occations when line number equals or is higher than 65535: When node contains only text, line number points to its end tag. When node has children, line number point to a first child node's starting tag. In other words, line number points to a node's starting tag when a line number is below 65535 and to a next occuring tag when line number is 65535 or higher. Reproducer: ------------ <?php if (!defined('LIBXML_VERSION') || LIBXML_VERSION < 20900) die('This test is for libxml >= 2.9.0'); define('LIBXML_BIGLINES', 1<<22); $foos = str_repeat('<foo/>' . PHP_EOL, 65526); $xml = <<<EOD <?xml version="1.0" encoding="UTF-8"?> <root> $foos <bar1> <yyy1>123</yyy1> <yyy2>123 </yyy2> </bar1> <bar2> <zzz1>123</zzz1> <zzz2>123 </zzz2> </bar2> </root> EOD; $dom = new DOMDocument(); $dom->loadXML($xml, LIBXML_BIGLINES); echo 'bar1: ' . $dom->getElementsByTagName('bar1')->item(0)->getLineNo() ."<br/>\n"; echo 'yyy1: ' . $dom->getElementsByTagName('yyy1')->item(0)->getLineNo() ."<br/>\n"; echo 'yyy2: ' . $dom->getElementsByTagName('yyy2')->item(0)->getLineNo() ."<br/>\n"; echo 'bar2: ' . $dom->getElementsByTagName('bar2')->item(0)->getLineNo() ."<br/>\n"; echo 'zzz1: ' . $dom->getElementsByTagName('zzz1')->item(0)->getLineNo() ."<br/>\n"; echo 'zzz2: ' . $dom->getElementsByTagName('zzz2')->item(0)->getLineNo() ."<br/>\n"; ?> Expected result: ---------------- bar1: 65530 yyy1: 65531 yyy2: 65532 bar2: 65535 zzz1: 65536 zzz2: 65537 Actual result: -------------- bar1: 65530 // OK yyy1: 65531 // OK yyy2: 65532 // OK bar2: 65536 // Error zzz1: 65536 // OK zzz2: 65538 // Error
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/libxml2/-/issues/ Thank you for your understanding and your help.