Bug 740707 - Fix crash in mozilla::dom::Navigator::GetMozBattery. r=jlebar
authorMounir Lamouri <mounir.lamouri@gmail.com>
Fri, 30 Mar 2012 18:58:12 -0700
changeset 90768 839c971b90223c70db47d2ed06023fa7217d9df9
parent 90767 44da25d479ef8fa9eecbc449a6af025644e0c9f4
child 90769 031949d40753cf8678ca9492c165a2ca885f330f
push id22382
push userbmo@edmorley.co.uk
push dateSat, 31 Mar 2012 21:44:34 +0000
treeherdermozilla-central@bbe5086163c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlebar
bugs740707
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 740707 - Fix crash in mozilla::dom::Navigator::GetMozBattery. r=jlebar
dom/base/Navigator.cpp
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -943,17 +943,17 @@ NS_IMETHODIMP Navigator::GetMozNotificat
 
 NS_IMETHODIMP
 Navigator::GetMozBattery(nsIDOMMozBatteryManager** aBattery)
 {
   if (!mBatteryManager) {
     *aBattery = nsnull;
 
     nsCOMPtr<nsPIDOMWindow> win(do_QueryReferent(mWindow));
-    NS_ENSURE_TRUE(win->GetDocShell(), NS_OK);
+    NS_ENSURE_TRUE(win && win->GetDocShell(), NS_OK);
 
     mBatteryManager = new battery::BatteryManager();
     mBatteryManager->Init(win);
   }
 
   NS_ADDREF(*aBattery = mBatteryManager);
 
   return NS_OK;