зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1276882 - Handle NaN sleep values explicitly; r=jandem
--HG-- extra : rebase_source : 08f79177e7d1a4a58952b6f95d952105105fdbaa
This commit is contained in:
Родитель
bbff6c938b
Коммит
05f6aaf959
|
@ -0,0 +1,5 @@
|
|||
// |jit-test| error: sleep interval is not a number
|
||||
sleep(0.001);
|
||||
1;
|
||||
sleep(0.1);
|
||||
sleep(this);
|
|
@ -3054,9 +3054,12 @@ Sleep_fn(JSContext* cx, unsigned argc, Value* vp)
|
|||
double t_secs;
|
||||
if (!ToNumber(cx, args[0], &t_secs))
|
||||
return false;
|
||||
duration = TimeDuration::FromSeconds(Max(0.0, t_secs));
|
||||
if (mozilla::IsNaN(t_secs)) {
|
||||
JS_ReportError(cx, "sleep interval is not a number");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* NB: The next condition also filter out NaNs. */
|
||||
duration = TimeDuration::FromSeconds(Max(0.0, t_secs));
|
||||
if (duration > MAX_TIMEOUT_INTERVAL) {
|
||||
JS_ReportError(cx, "Excessive sleep interval");
|
||||
return false;
|
||||
|
@ -3207,7 +3210,10 @@ CancelExecution(JSRuntime* rt)
|
|||
static bool
|
||||
SetTimeoutValue(JSContext* cx, double t)
|
||||
{
|
||||
/* NB: The next condition also filter out NaNs. */
|
||||
if (mozilla::IsNaN(t)) {
|
||||
JS_ReportError(cx, "timeout is not a number");
|
||||
return false;
|
||||
}
|
||||
if (TimeDuration::FromSeconds(t) > MAX_TIMEOUT_INTERVAL) {
|
||||
JS_ReportError(cx, "Excessive timeout value");
|
||||
return false;
|
||||
|
|
Загрузка…
Ссылка в новой задаче