LibWeb: Ignore non-finite args in CanvasRenderingContext2D.{scale,translate}()

This commit is contained in:
Linus Groh 2020-05-21 01:37:48 +01:00 committed by Andreas Kling
parent b962728c4e
commit 7defc521be
Notes: sideshowbarker 2024-07-19 06:17:09 +09:00

View file

@ -160,13 +160,14 @@ JS::Value CanvasRenderingContext2DWrapper::scale(JS::Interpreter& interpreter)
if (!impl)
return {};
if (interpreter.argument_count() >= 2) {
auto sx = interpreter.argument(0).to_double(interpreter);
auto sx = interpreter.argument(0).to_number(interpreter);
if (interpreter.exception())
return {};
auto sy = interpreter.argument(1).to_double(interpreter);
auto sy = interpreter.argument(1).to_number(interpreter);
if (interpreter.exception())
return {};
impl->scale(sx, sy);
if (sx.is_finite_number() && sy.is_finite_number())
impl->scale(sx.as_double(), sy.as_double());
}
return JS::js_undefined();
}
@ -177,13 +178,14 @@ JS::Value CanvasRenderingContext2DWrapper::translate(JS::Interpreter& interprete
if (!impl)
return {};
if (interpreter.argument_count() >= 2) {
auto tx = interpreter.argument(0).to_double(interpreter);
auto tx = interpreter.argument(0).to_number(interpreter);
if (interpreter.exception())
return {};
auto ty = interpreter.argument(1).to_double(interpreter);
auto ty = interpreter.argument(1).to_number(interpreter);
if (interpreter.exception())
return {};
impl->translate(tx, ty);
if (tx.is_finite_number() && ty.is_finite_number())
impl->translate(tx.as_double(), ty.as_double());
}
return JS::js_undefined();
}