diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index de392ea79ef8..e8f5dc1f3130 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -10990,9 +10990,11 @@ NS_IMETHODIMP nsNavigator::GetGeolocation(nsIDOMGeoGeolocation **_retval) 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; }