forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix phpGH-14638: null dereference after XML parsing failure.
object document is null if the parsing had failed prior to cast to string.
- Loading branch information
Showing
3 changed files
with
61 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--TEST-- | ||
GH-14638: null pointer dereference on object cast __toString after failed XML parsing | ||
--EXTENSIONS-- | ||
simplexml | ||
--CREDITS-- | ||
YuanchengJiang | ||
--FILE-- | ||
<?php | ||
$xml = '<?xml version="1.0" encoding="utf-8" ?> | ||
<test> | ||
</test>'; | ||
$root = simplexml_load_string($xml); | ||
try { | ||
$root->__construct("malformed"); | ||
} catch (Exception $e) { | ||
// Intentionally empty | ||
} | ||
echo $root; | ||
?> | ||
--EXPECTF-- | ||
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : Start tag expected, '<' not found in %s on line %d | ||
|
||
Warning: SimpleXMLElement::__construct(): malformed in %s on line %d | ||
|
||
Warning: SimpleXMLElement::__construct(): ^ in %s on line %d |