Fixing bug 324031. Make sure to do all the cleanup in all code paths. r=jonas@sicking.cc, sr=dveditz@cruzio.com

This commit is contained in:
jst%mozilla.jstenback.com 2006-01-21 00:57:26 +00:00
Родитель a1b2d0a045
Коммит 1456073f60
1 изменённых файлов: 35 добавлений и 18 удалений

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

@ -258,6 +258,13 @@ PR_STATIC_CALLBACK(void*) handleTriggerEvent(PLEvent* aEvent)
event->status );
if ( args )
{
// This code is all in a JS request, and here we're about to
// push the context onto the context stack and also push
// arguments. Be very very sure that no early returns creep in
// here w/o doing the proper cleanup!
const char *errorStr = nsnull;
nsCOMPtr<nsIJSContextStack> stack =
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
if (stack)
@ -268,33 +275,43 @@ PR_STATIC_CALLBACK(void*) handleTriggerEvent(PLEvent* aEvent)
if (!secman)
{
JS_ReportError(event->cx, "Could not get script security manager service");
return 0;
errorStr = "Could not get script security manager service";
}
nsCOMPtr<nsIPrincipal> principal;
secman->GetSubjectPrincipal(getter_AddRefs(principal));
if (!principal)
if (!errorStr)
{
JS_ReportError(event->cx, "Could not get principal from script security manager");
return 0;
secman->GetSubjectPrincipal(getter_AddRefs(principal));
if (!principal)
{
errorStr = "Could not get principal from script security manager";
}
}
PRBool equals = PR_FALSE;
principal->Equals(event->princ, &equals);
if (!equals)
if (!errorStr)
{
JS_ReportError(event->cx, "Principal of callback context is different then InstallTriggers");
return 0;
PRBool equals = PR_FALSE;
principal->Equals(event->princ, &equals);
if (!equals)
{
errorStr = "Principal of callback context is different than InstallTriggers";
}
}
JS_CallFunctionValue( event->cx,
JSVAL_TO_OBJECT(event->global),
event->cbval,
2,
args,
&ret );
if (errorStr)
{
JS_ReportError(event->cx, errorStr);
}
else
{
JS_CallFunctionValue(event->cx,
JSVAL_TO_OBJECT(event->global),
event->cbval,
2,
args,
&ret);
}
if (stack)
stack->Pop(nsnull);