Handle the case where f is null in "new f".

This commit is contained in:
norris%netscape.com 1999-05-04 17:23:13 +00:00
parent 108be1837b
commit 36803eaab9
2 changed files with 14 additions and 10 deletions

View File

@ -1282,13 +1282,15 @@ public class ScriptRuntime {
Function f;
try {
f = (Function) fun;
if (f != null)
return f.construct(cx, f.getParentScope(), args);
// else fall through to error
} catch (ClassCastException e) {
Object[] errorArgs = { toString(fun) };
throw Context.reportRuntimeError(cx.getMessage
("msg.isnt.function", errorArgs));
// fall through to error
}
// OPT: call construct directly?
return f.construct(cx, f.getParentScope(), args);
Object[] errorArgs = { toString(fun) };
throw Context.reportRuntimeError(cx.getMessage
("msg.isnt.function", errorArgs));
}
public static Scriptable newObjectSpecial(Context cx, Object fun,

View File

@ -1282,13 +1282,15 @@ public class ScriptRuntime {
Function f;
try {
f = (Function) fun;
if (f != null)
return f.construct(cx, f.getParentScope(), args);
// else fall through to error
} catch (ClassCastException e) {
Object[] errorArgs = { toString(fun) };
throw Context.reportRuntimeError(cx.getMessage
("msg.isnt.function", errorArgs));
// fall through to error
}
// OPT: call construct directly?
return f.construct(cx, f.getParentScope(), args);
Object[] errorArgs = { toString(fun) };
throw Context.reportRuntimeError(cx.getMessage
("msg.isnt.function", errorArgs));
}
public static Scriptable newObjectSpecial(Context cx, Object fun,