|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26947 Crash by using DomDocument::getElementById()
Submitted: 2004-01-17 12:57 UTC Modified: 2004-01-18 21:36 UTC
From: olivier dot bichler at laposte dot net Assigned:
Status: Closed Package: DOM XML related
PHP Version: 5.0.0b3 (beta3) OS: *
Private report: No CVE-ID: None
 [2004-01-17 12:57 UTC] olivier dot bichler at laposte dot net
PHP crash by using the DOM function getElementById() (PHP kill the Apache server process on Windows, with Apache v1.3.27 and v2.0.48).

Reproduce code:
$dom = new DomDocument;
$dom -> load('essai.xml');

if ($dom -> validate()) {
	$menu = new DomDocument;
	$menu = $dom -> getElementById('a');
	echo $menu -> firstChild -> data;

essai.xml :

<?xml version="1.0"?>
<!DOCTYPE essai [
	<!ELEMENT essai (truc+)>

	<!ELEMENT truc (#PCDATA)>
	<!ATTLIST truc

	<truc id="a">1</truc>

Expected result:

Actual result:
Nothing, PHP and the server crash...
There is the same result with an external doctype.
When I call getElementById(id) with an id who doesn't exist in the XML file, there is no crash.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-17 20:23 UTC]
Please try using this CVS snapshot:
For Windows:

 [2004-01-18 05:13 UTC]
It only crashes, if you use validate(). Without it seems to work.

I'm looking into it.

 [2004-01-18 07:52 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Sep 22 15:01:24 2023 UTC