@@ -415,8 +415,6 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value,
415415
416416 GET_NODE (sxe , node );
417417
418- php_libxml_invalidate_node_list_cache_from_doc (node -> doc );
419-
420418 if (sxe -> iter .type == SXE_ITER_ATTRLIST ) {
421419 attribs = 1 ;
422420 elements = 0 ;
@@ -477,6 +475,8 @@ static zval *sxe_prop_dim_write(zend_object *object, zval *member, zval *value,
477475 }
478476
479477 if (node ) {
478+ php_libxml_invalidate_node_list_cache_from_doc (node -> doc );
479+
480480 if (attribs ) {
481481 if (Z_TYPE_P (member ) == IS_LONG ) {
482482 while (attr && nodendx <= Z_LVAL_P (member )) {
@@ -619,6 +619,9 @@ static zval *sxe_property_get_adr(zend_object *object, zend_string *zname, int f
619619
620620 sxe = php_sxe_fetch_object (object );
621621 GET_NODE (sxe , node );
622+ if (UNEXPECTED (!node )) {
623+ return & EG (error_zval );
624+ }
622625 name = ZSTR_VAL (zname );
623626 node = sxe_get_element_by_name (sxe , node , name , & type );
624627 if (node ) {
@@ -788,8 +791,6 @@ static void sxe_prop_dim_delete(zend_object *object, zval *member, bool elements
788791
789792 GET_NODE (sxe , node );
790793
791- php_libxml_invalidate_node_list_cache_from_doc (node -> doc );
792-
793794 if (Z_TYPE_P (member ) == IS_LONG ) {
794795 if (sxe -> iter .type != SXE_ITER_ATTRLIST ) {
795796 attribs = 0 ;
@@ -813,6 +814,8 @@ static void sxe_prop_dim_delete(zend_object *object, zval *member, bool elements
813814 }
814815
815816 if (node ) {
817+ php_libxml_invalidate_node_list_cache_from_doc (node -> doc );
818+
816819 if (attribs ) {
817820 if (Z_TYPE_P (member ) == IS_LONG ) {
818821 int nodendx = 0 ;
@@ -1639,8 +1642,6 @@ PHP_METHOD(SimpleXMLElement, addChild)
16391642 sxe = Z_SXEOBJ_P (ZEND_THIS );
16401643 GET_NODE (sxe , node );
16411644
1642- php_libxml_invalidate_node_list_cache_from_doc (node -> doc );
1643-
16441645 if (sxe -> iter .type == SXE_ITER_ATTRLIST ) {
16451646 php_error_docref (NULL , E_WARNING , "Cannot add element to attributes" );
16461647 return ;
@@ -1653,6 +1654,8 @@ PHP_METHOD(SimpleXMLElement, addChild)
16531654 return ;
16541655 }
16551656
1657+ php_libxml_invalidate_node_list_cache_from_doc (node -> doc );
1658+
16561659 localname = xmlSplitQName2 ((xmlChar * )qname , & prefix );
16571660 if (localname == NULL ) {
16581661 localname = xmlStrdup ((xmlChar * )qname );
0 commit comments