LibWeb: Enforce set{Interval,Timeout}() min interval of 0

This commit is contained in:
Linus Groh 2020-05-21 01:12:33 +01:00 committed by Andreas Kling
parent c769784406
commit b962728c4e
Notes: sideshowbarker 2024-07-19 06:17:13 +09:00

View file

@ -141,6 +141,8 @@ JS::Value WindowObject::set_interval(JS::Interpreter& interpreter)
interval = interpreter.argument(1).to_i32(interpreter);
if (interpreter.exception())
return {};
if (interval < 0)
interval = 0;
}
impl->set_interval(*static_cast<JS::Function*>(callback_object), interval);
@ -165,6 +167,8 @@ JS::Value WindowObject::set_timeout(JS::Interpreter& interpreter)
interval = interpreter.argument(1).to_i32(interpreter);
if (interpreter.exception())
return {};
if (interval < 0)
interval = 0;
}
impl->set_timeout(*static_cast<JS::Function*>(callback_object), interval);