mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fix NULL pointer dereference with NULL content in legacy nodes in title getting (#15558)
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user