php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4258 xml_parse fails with 'out of memory'
Submitted: 2000-04-27 09:02 UTC Modified: 2000-04-27 22:36 UTC
From: mookid at sigent dot ru Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.16 OS: Linux-Mandrake 7.0
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mookid at sigent dot ru
New email:
PHP Version: OS:

 

 [2000-04-27 09:02 UTC] mookid at sigent dot ru
My XML parsing exercises have stuck with xml_parse() returning an 'out of memory' error. Here's a text script:

<?php

header('Content-Type: text/html');

function StartTag($parser, $tag, $attrs)
{
	echo "<$tag";
	while (list ($attr, $value) = each($attrs)) {
		echo " $attr";
		if (!empty($value)) {
			echo "=\"$value\"";
		}
	}
	echo ">";
}

$parser = xml_parser_create();
if (!$parser) {
	die('xml_parser_create failed: ' . xml_error_string($parser));
}
if (!xml_set_element_handler($parser, 'StartTag', FALSE)) {
	die('xml_set_element_handler failed: ' . xml_error_string($parser));
}

$data = '<tag attr1 attr2="this is a test &quot;&nbsp;"/>';
// $data = '';

if (!xml_parse($parser, $data, TRUE)) {
	die('xml_parse failed: ' . xml_error_string($parser));
}

?>

I'm using Apache 1.3.12 with the Russian patch.
Both Apache and PHP were compiled with Expat in mind, so that xml_* functions exist. This occurs on two Linux installations, one being Mandrake 7.0, other is the recent Slackware. Peeking at the source, I found that it's rather
Apache/Expat misbehaviour, and PHP source comments say something of that kind.

Any chance that it can be fixed?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-04-27 22:36 UTC] mookid at sigent dot ru
oops, I forgot to call xml_get_error_code(),
stupid me.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 01:01:33 2025 UTC