[php-src] master: Fix potential NULL pointer argument to memcpy (#13859)
| From: | Niels Dossche via GitHub | Date: | Mon, 01 Apr 2024 20:49:33 +0000 |
| Subject: | [php-src] master: Fix potential NULL pointer argument to memcpy (#13859) | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-127930@lists.php.net to get a copy of this message | ||
Author: Niels Dossche (nielsdos)
Committer: GitHub (web-flow)
Pusher: nielsdos
Date: 2024-04-01T22:47:38+02:00
Commit: https://github.com/php/php-src/commit/ce2dd0b20bb2d3faff717ab948f7d09bb3749e09
Raw diff: https://github.com/php/php-src/commit/ce2dd0b20bb2d3faff717ab948f7d09bb3749e09.diff
Fix potential NULL pointer argument to memcpy (#13859)
This is only possible when the length is 0, but memcpy doesn't like NULL
pointers, as UBSAN trips over it.
Changed paths:
M ext/dom/html5_parser.c
Diff:
diff --git a/ext/dom/html5_parser.c b/ext/dom/html5_parser.c
index 68bb9bcc6974..973586155078 100644
--- a/ext/dom/html5_parser.c
+++ b/ext/dom/html5_parser.c
@@ -86,7 +86,9 @@ static xmlNodePtr lexbor_libxml2_bridge_new_text_node_fast(xmlDocPtr lxml_doc, c
lxml_text->type = XML_TEXT_NODE;
lxml_text->doc = lxml_doc;
lxml_text->content = BAD_CAST &lxml_text->properties;
- memcpy(lxml_text->content, data, data_length);
+ if (data != NULL) {
+ memcpy(lxml_text->content, data, data_length);
+ }
return lxml_text;
} else {
return xmlNewDocTextLen(lxml_doc, (const xmlChar *) data, data_length);