summaryrefslogtreecommitdiff
path: root/ext/simplexml/simplexml.c
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2018-08-07 11:37:58 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2018-08-25 14:24:09 +0200
commit692e5d5c88a939a7c3ce3de61c5fd39effe7c7ae (patch)
treeb7b3d65a70f4d57d54a0ffb7c1b73939c1f3198a /ext/simplexml/simplexml.c
parentfcf4088d3fe27a3c950985afc49af1064c54b024 (diff)
downloadphp-git-692e5d5c88a939a7c3ce3de61c5fd39effe7c7ae.tar.gz
Fix #76712: Assignment of empty string creates extraneous text node
We work around this peculiarity of libxml by using xmlNodeSetContent(), which does not exhibit this behavior. This also saves us from manually calculating the string length.
Diffstat (limited to 'ext/simplexml/simplexml.c')
-rw-r--r--ext/simplexml/simplexml.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 92e6de107a..ab394b5c83 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -384,7 +384,6 @@ static zval *sxe_dimension_read(zval *object, zval *offset, int type, zval *rv)
static void change_node_zval(xmlNodePtr node, zval *value)
{
xmlChar *buffer;
- int buffer_len;
if (!value)
{
@@ -401,10 +400,9 @@ static void change_node_zval(xmlNodePtr node, zval *value)
/* break missing intentionally */
case IS_STRING:
buffer = xmlEncodeEntitiesReentrant(node->doc, (xmlChar *)Z_STRVAL_P(value));
- buffer_len = xmlStrlen(buffer);
/* check for NULL buffer in case of memory error in xmlEncodeEntitiesReentrant */
if (buffer) {
- xmlNodeSetContentLen(node, buffer, buffer_len);
+ xmlNodeSetContent(node, buffer);
xmlFree(buffer);
}
break;