Bug 630883 Crash at [@ nsDOMWindowUtils::FindElementWithViewID] r=cjones a=blocking-fennec
authorBenjamin Stover <bstover@mozilla.com>
Wed, 02 Feb 2011 13:35:03 -0800
changeset 61804 c0397dc901f46fa2aedd8e6c990f51e70259ef05
parent 61803 e9c5611100b73b555d1173d1c36d10a60f09639d
child 61807 b0325a41a1670c42bb9f9a27c61427b28a05fbe1
push idunknown
push userunknown
push dateunknown
reviewerscjones, blocking-fennec
bugs630883
milestone2.0b12pre
Bug 630883 Crash at [@ nsDOMWindowUtils::FindElementWithViewID] r=cjones a=blocking-fennec
dom/base/nsDOMWindowUtils.cpp
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -993,27 +993,32 @@ nsDOMWindowUtils::GetFocusedInputType(ch
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::FindElementWithViewId(nsViewID aID,
                                         nsIDOMElement** aResult)
 {
   if (aID == FrameMetrics::ROOT_SCROLL_ID) {
     nsPresContext* presContext = GetPresContext();
+    if (!presContext) {
+      return NS_ERROR_NOT_AVAILABLE;
+    }
+
     nsIDocument* document = presContext->Document();
     mozilla::dom::Element* rootElement = document->GetRootElement();
     if (!rootElement) {
       return NS_ERROR_NOT_AVAILABLE;
     }
+
     CallQueryInterface(rootElement, aResult);
     return NS_OK;
   }
 
   nsRefPtr<nsIContent> content = nsLayoutUtils::FindContentFor(aID);
-  return CallQueryInterface(content, aResult);
+  return content ? CallQueryInterface(content, aResult) : NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::GetScreenPixelsPerCSSPixel(float* aScreenPixels)
 {
   *aScreenPixels = 1;
 
   if (!nsContentUtils::IsCallerTrustedForRead())