#47220 [NEW]: segfault in dom_document_parser in recovery mode

From: Date: Mon, 26 Jan 2009 16:54:48 +0000
Subject: #47220 [NEW]: segfault in dom_document_parser in recovery mode
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-133226@lists.php.net to get a copy of this message
From:             felix-php at 7val dot com
Operating system: Debian Linux
PHP version:      5.2.8
PHP Bug Type:     DOM XML related
Bug description:  segfault in dom_document_parser in recovery mode

Description:
------------
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:
---------------
<?php
$xml = '<?xml version="1.0" encoding="bad"?>';
$dom = new DOMDocument;
$dom->recover = true;
$dom->loadXML($xml);
echo $dom->saveXML();

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

Actual result:
--------------
Segmentation Fault

-- 
Edit bug report at http://bugs.php.net/?id=47220&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        http://bugs.php.net/fix.php?id=47220&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        http://bugs.php.net/fix.php?id=47220&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        http://bugs.php.net/fix.php?id=47220&r=trysnapshot60
Fixed in CVS:                        http://bugs.php.net/fix.php?id=47220&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47220&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=47220&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=47220&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=47220&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=47220&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=47220&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=47220&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=47220&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=47220&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=47220&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=47220&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=47220&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=47220&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=47220&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=47220&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=47220&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=47220&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#133226) next »