mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fix NULL pointer dereference with NULL content in legacy nodes in title getting (#15558)
This commit is contained in:
parent
7ae7b4e388
commit
d32b97a1c7
2 changed files with 6 additions and 1 deletions
|
@ -1467,7 +1467,7 @@ static zend_string *dom_get_child_text_content(const xmlNode *node)
|
|||
|
||||
const xmlNode *text = node->children;
|
||||
while (text != NULL) {
|
||||
if (text->type == XML_TEXT_NODE || text->type == XML_CDATA_SECTION_NODE) {
|
||||
if ((text->type == XML_TEXT_NODE || text->type == XML_CDATA_SECTION_NODE) && text->content != NULL) {
|
||||
smart_str_appends(&content, (const char *) text->content);
|
||||
}
|
||||
text = text->next;
|
||||
|
|
|
@ -43,6 +43,10 @@ var_dump($dom->title);
|
|||
$dom = Dom\XMLDocument::createFromString("<root xmlns=\"http://www.w3.org/1999/xhtml\"><title>title\nhere</title></root>");
|
||||
var_dump($dom->title);
|
||||
|
||||
$dom = Dom\XMLDocument::createFromString("<root xmlns=\"http://www.w3.org/1999/xhtml\"><title/></root>");
|
||||
$dom->getElementsByTagName('title')[0]->appendChild($dom->importLegacyNode(new DOMText));
|
||||
var_dump($dom->title);
|
||||
|
||||
echo "=== SVG namespaced root ===\n";
|
||||
|
||||
$dom = Dom\XMLDocument::createFromString("<root xmlns=\"http://www.w3.org/1999/xhtml\"><title>title</title></root>");
|
||||
|
@ -72,6 +76,7 @@ string(0) ""
|
|||
string(2) "xz"
|
||||
string(2) "yw"
|
||||
string(10) "title here"
|
||||
string(0) ""
|
||||
=== SVG namespaced root ===
|
||||
string(5) "title"
|
||||
string(5) "title"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue