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

This commit is contained in:
valeski%netscape.com 2001-05-25 14:58:33 +00:00
Родитель f7e128a2c0
Коммит 594d30706b
1 изменённых файлов: 6 добавлений и 3 удалений

Просмотреть файл

@ -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));