mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Don't add 1 when calling xmlNodeSetContent()
The length is passed to xmlStrndup(), which also adds 1, and adds a null terminator past the end. It worked because the length is not actually stored. Strings in libxml2 are null terminated. Passing the length just avoids a call to strlen().
This commit is contained in:
parent
74910b1403
commit
ee68c22128
3 changed files with 3 additions and 3 deletions
|
@ -70,7 +70,7 @@ int dom_characterdata_data_write(dom_object *obj, zval *newval)
|
|||
return FAILURE;
|
||||
}
|
||||
|
||||
xmlNodeSetContentLen(nodep, (xmlChar *) ZSTR_VAL(str), ZSTR_LEN(str) + 1);
|
||||
xmlNodeSetContentLen(nodep, (xmlChar *) ZSTR_VAL(str), ZSTR_LEN(str));
|
||||
|
||||
zend_string_release_ex(str, 0);
|
||||
return SUCCESS;
|
||||
|
|
|
@ -185,7 +185,7 @@ int dom_node_node_value_write(dom_object *obj, zval *newval)
|
|||
case XML_COMMENT_NODE:
|
||||
case XML_CDATA_SECTION_NODE:
|
||||
case XML_PI_NODE:
|
||||
xmlNodeSetContentLen(nodep, (xmlChar *) ZSTR_VAL(str), ZSTR_LEN(str) + 1);
|
||||
xmlNodeSetContentLen(nodep, (xmlChar *) ZSTR_VAL(str), ZSTR_LEN(str));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -130,7 +130,7 @@ int dom_processinginstruction_data_write(dom_object *obj, zval *newval)
|
|||
|
||||
php_libxml_invalidate_node_list_cache_from_doc(nodep->doc);
|
||||
|
||||
xmlNodeSetContentLen(nodep, (xmlChar *) ZSTR_VAL(str), ZSTR_LEN(str) + 1);
|
||||
xmlNodeSetContentLen(nodep, (xmlChar *) ZSTR_VAL(str), ZSTR_LEN(str));
|
||||
|
||||
zend_string_release_ex(str, 0);
|
||||
return SUCCESS;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue