From 3c55e1f0aa130233179da40b0a40a88ce0618392 Mon Sep 17 00:00:00 2001 From: "caillon%returnzero.com" Date: Sat, 17 Aug 2002 01:43:07 +0000 Subject: [PATCH] 119044 - Prevent a crash when trying to append/insert the current element or one of its ancestors into itself. Throw the correct exception in this case per the DOM spec. Thanks to Neil Deakin for pinpointing this and providing a patch. r=bryner/caillon sr=jst git-svn-id: svn://10.0.0.236/trunk@127522 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/xul/content/src/nsXULElement.cpp | 5 +++++ 1 file changed, 5 insertions(+) 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)