1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Minor cleanup in dom_node_concatenated_name_helper() (#13639)

This commit is contained in:
Niels Dossche
2024-03-09 10:12:49 +01:00
committed by GitHub
parent f9ddd2b0c8
commit 82897fc447

View File

@@ -32,10 +32,8 @@
zend_string *dom_node_concatenated_name_helper(size_t name_len, const char *name, size_t prefix_len, const char *prefix)
{
if (UNEXPECTED(prefix_len > ZSTR_MAX_LEN / 2 - 1 || name_len > ZSTR_MAX_LEN / 2 - 1)) {
return zend_empty_string;
}
zend_string *str = zend_string_alloc(prefix_len + 1 + name_len, false);
/* prefix_len can't overflow because it would need to occupy the entire address space */
zend_string *str = zend_string_safe_alloc(1, name_len, prefix_len + 1, false);
memcpy(ZSTR_VAL(str), prefix, prefix_len);
ZSTR_VAL(str)[prefix_len] = ':';
memcpy(ZSTR_VAL(str) + prefix_len + 1, name, name_len + 1 /* include \0 */);