[php-src] Issue #14684: DomDocument::loadXML cannot parse files larger than 1,3 GiB

From: Date: Thu, 27 Jun 2024 07:13:58 +0000
Subject: [php-src] Issue #14684: DomDocument::loadXML cannot parse files larger than 1,3 GiB
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-247156@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/14684 Author: pjpawel ### Description The following code: ```php <?php function loadXMLFile($filename) { $content = file_get_contents($filename); $doc = new DOMDocument(); $success = $doc->loadXML($content); if (!$success) { echo "Failed to parse $filename\n"; return null; } return $doc; } function main($filename) { $doc = loadXMLFile($filename); if ($doc !== null) { $root = $doc->documentElement; echo "Root element: " . $root->nodeName . "\n"; } else { echo "Empty document or failed to load.\n"; } } if ($argc != 2) { echo "Usage: php " . $argv[0] . " <xmlfile>\n"; exit(1); } main($argv[1]); ``` Resulted in this output: ``` PHP Warning: DOMDocument::loadXML(): Memory allocation failed : growing input buffer in domLoadXml.php on line 8 Warning: DOMDocument::loadXML(): Memory allocation failed : growing input buffer in domLoadXml.php on line 8 Root element: tns:JPK ``` But I expected this output instead: ``` Root element: tns:JPK ``` I tried using option LIBXML_PARSEHUGE, but result was the same. The most curious thing is that DomDocument::load() is loading large files correctly. ### PHP Version 8.2.5 ### Operating System Windows 11, Ubuntu 22.04

« previous php.bugs (#247156) next »