mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-12 02:31:41 +00:00
141056 r=hawara sr=dveditz a=asa
add error checking to fix top crasher
This commit is contained in:
parent
829445ae98
commit
94223fb09b
@ -180,6 +180,8 @@ NS_IMETHODIMP_(void) LocationImpl::SetDocShell(nsIDocShell *aDocShell)
|
||||
nsresult
|
||||
LocationImpl::CheckURL(nsIURI* aURI, nsIDocShellLoadInfo** aLoadInfo)
|
||||
{
|
||||
*aLoadInfo = nsnull;
|
||||
|
||||
nsresult result;
|
||||
// Get JSContext from stack.
|
||||
nsCOMPtr<nsIJSContextStack>
|
||||
@ -193,6 +195,16 @@ LocationImpl::CheckURL(nsIURI* aURI, nsIDocShellLoadInfo** aLoadInfo)
|
||||
if (NS_FAILED(stack->Peek(&cx)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (!cx) {
|
||||
// No cx means that there's no JS running, or at least no JS that
|
||||
// was run through code that properly pushed a context onto the
|
||||
// context stack (as all code that runs JS off of web pages
|
||||
// does). Going further from here will crash, so lets not do
|
||||
// that...
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get security manager.
|
||||
nsCOMPtr<nsIScriptSecurityManager>
|
||||
secMan(do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &result));
|
||||
|
Loading…
x
Reference in New Issue
Block a user