diff --git a/uriloader/base/nsDocLoader.cpp b/uriloader/base/nsDocLoader.cpp index bd1dfcb258c6..de08daf4a61e 100644 --- a/uriloader/base/nsDocLoader.cpp +++ b/uriloader/base/nsDocLoader.cpp @@ -952,17 +952,18 @@ nsDocLoader::GetIsTopLevel(bool *aResult) *aResult = false; nsCOMPtr window; - nsresult rv = GetDOMWindow(getter_AddRefs(window)); - NS_ENSURE_SUCCESS(rv, rv); + GetDOMWindow(getter_AddRefs(window)); + if (window) { + nsCOMPtr piwindow = do_QueryInterface(window); + NS_ENSURE_STATE(piwindow); - nsCOMPtr piwindow = do_QueryInterface(window); - NS_ENSURE_STATE(piwindow); + nsCOMPtr topWindow; + nsresult rv = piwindow->GetTop(getter_AddRefs(topWindow)); + NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr topWindow; - rv = piwindow->GetTop(getter_AddRefs(topWindow)); - NS_ENSURE_SUCCESS(rv, rv); + *aResult = piwindow == topWindow; + } - *aResult = piwindow == topWindow; return NS_OK; }