Bug 1249377 - Hold a strong reference to |root| in nsHTMLDocument::SetBody. r=bz, a=sylvestre
authorAndrew McCreight <continuation@gmail.com>
Fri, 19 Feb 2016 06:26:07 -0800
changeset 313156 b208427885d3
parent 313155 e2b86793693f
child 313157 85b2e3b672e5
push id1040
push userraliiev@mozilla.com
push date2016-02-29 17:11 +0000
Treeherderresults
reviewersbz, sylvestre
bugs1249377
milestone45.0
Bug 1249377 - Hold a strong reference to |root| in nsHTMLDocument::SetBody. r=bz, a=sylvestre
dom/html/nsHTMLDocument.cpp
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -1029,17 +1029,17 @@ nsHTMLDocument::SetBody(nsIDOMHTMLElemen
   ErrorResult rv;
   SetBody(static_cast<nsGenericHTMLElement*>(newBody.get()), rv);
   return rv.StealNSResult();
 }
 
 void
 nsHTMLDocument::SetBody(nsGenericHTMLElement* newBody, ErrorResult& rv)
 {
-  Element* root = GetRootElement();
+  nsCOMPtr<Element> root = GetRootElement();
 
   // The body element must be either a body tag or a frameset tag. And we must
   // have a html root tag, otherwise GetBody will not return the newly set
   // body.
   if (!newBody ||
       !newBody->IsAnyOfHTMLElements(nsGkAtoms::body, nsGkAtoms::frameset) ||
       !root || !root->IsHTMLElement() ||
       !root->IsHTMLElement(nsGkAtoms::html)) {