r=jband, sr=vidur, a=blizzard. 82536. adding null check and graceful failing if null. it's valid for the stack to pop null JSContexts

git-svn-id: svn://10.0.0.236/trunk@95912 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
valeski%netscape.com
2001-05-25 14:58:33 +00:00
parent 8932054c7a
commit 8b114fc235

View File

@@ -638,9 +638,12 @@ nsHTMLImageElement::GetCallerSourceURL(nsIURI** sourceURL)
if (NS_FAILED(result))
return NS_ERROR_FAILURE;
JSContext *cx;
JSContext *cx = nsnull;
if (NS_FAILED(stack->Peek(&cx)))
// it's possible that there is not a JSContext on the stack.
// specifically this can happen when the DOM is being manipulated
// from native (non-JS) code.
if (NS_FAILED(stack->Peek(&cx)) || !cx)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIScriptGlobalObject> global;
@@ -1054,7 +1057,7 @@ nsHTMLImageElement::SetSrc(const nsAReadableString& aSrc)
nsCOMPtr<nsIURI> baseURL;
nsresult result = NS_OK;
GetCallerSourceURL(getter_AddRefs(baseURL));
(void) GetCallerSourceURL(getter_AddRefs(baseURL));
if (mDocument && !baseURL) {
result = mDocument->GetBaseURL(*getter_AddRefs(baseURL));