mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Protect against null contexts. bug 340602, r+sr=roc
This commit is contained in:
parent
efa80a10a5
commit
8f01b34f73
@ -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…
Reference in New Issue
Block a user