Bug 1257223 - Fix os.file.redirect(null), r=jonco

--HG--
extra : rebase_source : 47f402c85b7df994db56d69559dfcb528e7b95d4
extra : amend_source : bea76dd9db5c5f48f59819daf2184bafd303b492
This commit is contained in:
Steve Fink 2016-03-16 11:04:22 -07:00
parent e6b62e1073
commit 07ed9e0dde

View File

@ -447,7 +447,8 @@ static bool
Redirect(JSContext* cx, const CallArgs& args, RCFile** outFile)
{
if (args.length() > 1) {
JS_ReportErrorNumber(cx, js::shell::my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, "redirect");
JS_ReportErrorNumber(cx, js::shell::my_GetErrorMessage, nullptr,
JSSMSG_INVALID_ARGS, "redirect");
return false;
}
@ -478,9 +479,12 @@ Redirect(JSContext* cx, const CallArgs& args, RCFile** outFile)
}
}
RootedString filename(cx, JS::ToString(cx, args[0]));
if (!filename)
return false;
RootedString filename(cx);
if (!args[0].isNull()) {
filename = JS::ToString(cx, args[0]);
if (!filename)
return false;
}
if (!redirect(cx, filename, outFile))
return false;