Protect against null contexts. bug 340602, r+sr=roc
git-svn-id: svn://10.0.0.236/trunk@199426 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
6ae0a06c16
commit
76bebc65c0
@ -2234,19 +2234,23 @@ IsContextOnStack(nsIJSContextStack *aStack, JSContext *aContext)
|
||||
return PR_FALSE;
|
||||
if (ctx == aContext)
|
||||
return PR_TRUE;
|
||||
|
||||
|
||||
nsCOMPtr<nsIJSContextStackIterator>
|
||||
iterator(do_CreateInstance("@mozilla.org/js/xpc/ContextStackIterator;1"));
|
||||
NS_ENSURE_TRUE(iterator, PR_FALSE);
|
||||
|
||||
nsresult rv = iterator->Reset(aStack);
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
|
||||
|
||||
PRBool done;
|
||||
while (NS_SUCCEEDED(iterator->Done(&done)) && !done) {
|
||||
rv = iterator->Prev(&ctx);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Broken iterator implementation");
|
||||
|
||||
if (!ctx) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nsJSUtils::GetDynamicScriptContext(ctx) && ctx == aContext)
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
@ -82,12 +82,17 @@ GetContextFromStack(nsIJSContextStack *aStack, JSContext **aContext)
|
||||
|
||||
nsresult rv = iterator->Reset(aStack);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
PRBool done;
|
||||
while (NS_SUCCEEDED(iterator->Done(&done)) && !done) {
|
||||
rv = iterator->Prev(aContext);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Broken iterator implementation");
|
||||
|
||||
// Consider a null context the end of the line.
|
||||
if (!*aContext) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (nsJSUtils::GetDynamicScriptContext(*aContext)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user