]> granicus.if.org Git - php/commitdiff
Simplify change_node_zval implementation
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 25 Aug 2020 09:01:22 +0000 (11:01 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 25 Aug 2020 09:01:48 +0000 (11:01 +0200)
At this point, the value has already been converted into a string.

ext/simplexml/simplexml.c

index afd655aeedd736c4f0a14d0e1d0041bdf4a8efbd..42a7ccb192d5b6d1ff1a34896248c2d05b141c1b 100644 (file)
@@ -377,31 +377,12 @@ static zval *sxe_dimension_read(zend_object *object, zval *offset, int type, zva
 static void change_node_zval(xmlNodePtr node, zval *value)
 {
        xmlChar *buffer;
-
-       if (!value)
-       {
-               xmlNodeSetContentLen(node, (xmlChar *)"", 0);
-               return;
-       }
-       switch (Z_TYPE_P(value)) {
-               case IS_LONG:
-               case IS_FALSE:
-               case IS_TRUE:
-               case IS_DOUBLE:
-               case IS_NULL:
-                       convert_to_string(value);
-                       /* break missing intentionally */
-               case IS_STRING:
-                       buffer = xmlEncodeEntitiesReentrant(node->doc, (xmlChar *)Z_STRVAL_P(value));
-                       /* check for NULL buffer in case of memory error in xmlEncodeEntitiesReentrant */
-                       if (buffer) {
-                               xmlNodeSetContent(node, buffer);
-                               xmlFree(buffer);
-                       }
-                       break;
-               default:
-                       php_error_docref(NULL, E_WARNING, "It is not possible to assign complex types to nodes");
-                       break;
+       ZEND_ASSERT(Z_TYPE_P(value) == IS_STRING);
+       buffer = xmlEncodeEntitiesReentrant(node->doc, (xmlChar *)Z_STRVAL_P(value));
+       /* check for NULL buffer in case of memory error in xmlEncodeEntitiesReentrant */
+       if (buffer) {
+               xmlNodeSetContent(node, buffer);
+               xmlFree(buffer);
        }
 }
 /* }}} */