diff --git a/xinclude.c b/xinclude.c index 09c1eef4..9e7a2bed 100644 --- a/xinclude.c +++ b/xinclude.c @@ -733,10 +733,11 @@ xmlXIncludeCopyNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr elem, return(result); while (cur->next == NULL) { + if (insertParent != NULL) + insertParent->last = insertLast; cur = cur->parent; if (cur == elem) return(result); - insertParent->last = insertLast; insertLast = insertParent; insertParent = insertParent->parent; }