diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 54cad459ee6..ac849cd1df4 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -993,6 +993,11 @@ nsXULElement::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, if (NS_FAILED(rv)) return rv; + // We can't insert an ancestor or ourself. + if (IsAncestor(aNewChild, this)) { + return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR; + } + nsCOMPtr newcontent = do_QueryInterface(aNewChild); NS_ASSERTION(newcontent != nsnull, "not an nsIContent"); if (! newcontent)