mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix GH-15570: Segmentation fault (access null pointer) in ext/dom/html5_serializer.c
Closes GH-15572.
This commit is contained in:
parent
2ca4f31bc7
commit
690ce6d5d4
3 changed files with 23 additions and 2 deletions
2
NEWS
2
NEWS
|
@ -24,6 +24,8 @@ PHP NEWS
|
||||||
- DOM:
|
- DOM:
|
||||||
. Fixed bug GH-15551 (Segmentation fault (access null pointer) in
|
. Fixed bug GH-15551 (Segmentation fault (access null pointer) in
|
||||||
ext/dom/xml_common.h). (nielsdos)
|
ext/dom/xml_common.h). (nielsdos)
|
||||||
|
. Fixed bug GH-15570 (Segmentation fault (access null pointer) in
|
||||||
|
ext/dom/html5_serializer.c). (nielsdos)
|
||||||
|
|
||||||
- FPM:
|
- FPM:
|
||||||
. Added memory peak to the scoreboard / status page. (Flávio Heleno)
|
. Added memory peak to the scoreboard / status page. (Flávio Heleno)
|
||||||
|
|
|
@ -137,8 +137,8 @@ static zend_result dom_html5_serialize_text_node(dom_html5_serialize_context *ct
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node->parent->type == XML_ELEMENT_NODE && php_dom_ns_is_fast(node->parent, php_dom_ns_is_html_magic_token)) {
|
const xmlNode *parent = node->parent;
|
||||||
const xmlNode *parent = node->parent;
|
if (parent != NULL && parent->type == XML_ELEMENT_NODE && php_dom_ns_is_fast(parent, php_dom_ns_is_html_magic_token)) {
|
||||||
size_t name_length = strlen((const char *) parent->name);
|
size_t name_length = strlen((const char *) parent->name);
|
||||||
/* Spec tells us to only emit noscript content as-is if scripting is enabled.
|
/* Spec tells us to only emit noscript content as-is if scripting is enabled.
|
||||||
* However, the user agent (PHP) does not support (JS) scripting.
|
* However, the user agent (PHP) does not support (JS) scripting.
|
||||||
|
|
19
ext/dom/tests/gh15570.phpt
Normal file
19
ext/dom/tests/gh15570.phpt
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
--TEST--
|
||||||
|
GH-15570 (Segmentation fault (access null pointer) in ext/dom/html5_serializer.c)
|
||||||
|
--CREDITS--
|
||||||
|
YuanchengJiang
|
||||||
|
--EXTENSIONS--
|
||||||
|
dom
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$html = <<<HTML
|
||||||
|
<head>
|
||||||
|
</html>
|
||||||
|
HTML;
|
||||||
|
$dom = Dom\HTMLDocument::createFromString($html, LIBXML_NOERROR);
|
||||||
|
$a = $dom->head->firstChild->cloneNode(false);
|
||||||
|
var_dump($dom->saveHTML($a));
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
string(1) "
|
||||||
|
"
|
Loading…
Add table
Add a link
Reference in a new issue