Bug 640201 - If nsGeolocation::Init fails, mGeolocation is not clear and will be returned on subsequent calls. r=jst
authorDoug Turner <dougt@dougt.org>
Wed, 23 Mar 2011 10:27:51 -0700
changeset 63551 a8eb404a4286a9d6d3bb4ce682081229c3f55a48
parent 63550 4dcf1c5c0c3fc901cc6a43df0db71d47e3681e65
child 63552 ebb87a57ed5b07336bdd4d26241400daacdb7bc2
push idunknown
push userunknown
push dateunknown
reviewersjst
bugs640201
milestone2.2a1pre
Bug 640201 - If nsGeolocation::Init fails, mGeolocation is not clear and will be returned on subsequent calls. r=jst
dom/base/nsGlobalWindow.cpp
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -10985,19 +10985,21 @@ NS_IMETHODIMP nsNavigator::GetGeolocatio
   nsCOMPtr<nsIDOMWindow> contentDOMWindow(do_GetInterface(mDocShell));
   if (!contentDOMWindow)
     return NS_ERROR_FAILURE;
     
   mGeolocation = new nsGeolocation();
   if (!mGeolocation)
     return NS_ERROR_FAILURE;
   
-  if (NS_FAILED(mGeolocation->Init(contentDOMWindow)))
+  if (NS_FAILED(mGeolocation->Init(contentDOMWindow))) {
+    mGeolocation = nsnull;
     return NS_ERROR_FAILURE;
-  
+  }
+
   NS_ADDREF(*_retval = mGeolocation);    
   return NS_OK; 
 }
 
 
 //*****************************************************************************
 //    nsNavigator::nsIDOMNavigatorDesktopNotification
 //*****************************************************************************