|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47220 segfault in dom_document_parser in recovery mode
Submitted: 2009-01-26 16:54 UTC Modified: 2009-01-26 20:04 UTC
From: felix-php at 7val dot com Assigned:
Status: Closed Package: DOM XML related
PHP Version: 5.2.8 OS: Debian Linux
Private report: No CVE-ID: None
 [2009-01-26 16:54 UTC] felix-php at 7val dot com
A call to DOMDocument::load() or ::loadXML() in recovery mode leads to segmentation fault in dom_document_parser) when the XML declaration contains an unknown (and unrecoverable) encoding.

The segfault occurs in document.c +1690 when trying to access properties of the result document (ret), which is NULL in this case:

  if (ret->URL == NULL && ctxt->directory != NULL) {

Reproduce code:
$xml = '<?xml version="1.0" encoding="bad"?>';
$dom = new DOMDocument;
$dom->recover = true;
echo $dom->saveXML();

Expected result:
<?xml version="1.0"?>

Actual result:
Segmentation Fault


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-26 20:05 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-2019 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 10:01:25 2019 UTC