Skip to content

Commit ce2dd0b

Browse files
authored
Fix potential NULL pointer argument to memcpy (php#13859)
This is only possible when the length is 0, but memcpy doesn't like NULL pointers, as UBSAN trips over it.
1 parent eb1cdb5 commit ce2dd0b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ext/dom/html5_parser.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ static xmlNodePtr lexbor_libxml2_bridge_new_text_node_fast(xmlDocPtr lxml_doc, c
8686
lxml_text->type = XML_TEXT_NODE;
8787
lxml_text->doc = lxml_doc;
8888
lxml_text->content = BAD_CAST &lxml_text->properties;
89-
memcpy(lxml_text->content, data, data_length);
89+
if (data != NULL) {
90+
memcpy(lxml_text->content, data, data_length);
91+
}
9092
return lxml_text;
9193
} else {
9294
return xmlNewDocTextLen(lxml_doc, (const xmlChar *) data, data_length);

0 commit comments

Comments
 (0)