summaryrefslogtreecommitdiff
path: root/ext/dom/php_dom.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dom/php_dom.c')
-rw-r--r--ext/dom/php_dom.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c
index 11f7f9684b..fd62a925c2 100644
--- a/ext/dom/php_dom.c
+++ b/ext/dom/php_dom.c
@@ -1122,7 +1122,7 @@ void dom_get_elements_by_tag_name_ns_raw(xmlNodePtr nodep, char *ns, char *local
/* {{{ void dom_normalize (xmlNodePtr nodep TSRMLS_DC) */
void dom_normalize (xmlNodePtr nodep TSRMLS_DC)
{
- xmlNodePtr child, nextp;
+ xmlNodePtr child, nextp, newnextp;
xmlAttrPtr attr;
xmlChar *strContent;
@@ -1133,12 +1133,15 @@ void dom_normalize (xmlNodePtr nodep TSRMLS_DC)
nextp = child->next;
while (nextp != NULL) {
if (nextp->type == XML_TEXT_NODE) {
+ newnextp = nextp->next;
strContent = xmlNodeGetContent(nextp);
xmlNodeAddContent(child, strContent);
xmlFree(strContent);
xmlUnlinkNode(nextp);
node_free_resource(nextp TSRMLS_CC);
- nextp = child->next;
+ nextp = newnextp;
+ } else {
+ break;
}
}
break;