mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:57:44 +00:00
LibWeb: Don't divide by 0 in DOMMatrix::invert_self()
We'd only check is_invertible() after calling inverse(), which would do a divide-by-0 for non-invertible matrices. Less ambitious version of #18593.
This commit is contained in:
parent
3811be2f7c
commit
2abe62adfa
1 changed files with 5 additions and 2 deletions
|
@ -252,11 +252,14 @@ void DOMMatrix::set_f(double value)
|
||||||
// https://drafts.fxtf.org/geometry/#dom-dommatrix-invertself
|
// https://drafts.fxtf.org/geometry/#dom-dommatrix-invertself
|
||||||
JS::NonnullGCPtr<DOMMatrix> DOMMatrix::invert_self()
|
JS::NonnullGCPtr<DOMMatrix> DOMMatrix::invert_self()
|
||||||
{
|
{
|
||||||
|
bool is_invertible = m_matrix.is_invertible();
|
||||||
|
|
||||||
// 1. Invert the current matrix.
|
// 1. Invert the current matrix.
|
||||||
m_matrix = m_matrix.inverse();
|
if (is_invertible)
|
||||||
|
m_matrix = m_matrix.inverse();
|
||||||
|
|
||||||
// 2. If the current matrix is not invertible set all attributes to NaN and set is 2D to false.
|
// 2. If the current matrix is not invertible set all attributes to NaN and set is 2D to false.
|
||||||
if (!m_matrix.is_invertible()) {
|
if (!is_invertible) {
|
||||||
for (u8 i = 0; i < 4; i++) {
|
for (u8 i = 0; i < 4; i++) {
|
||||||
for (u8 j = 0; j < 4; j++)
|
for (u8 j = 0; j < 4; j++)
|
||||||
m_matrix.elements()[i][j] = NAN;
|
m_matrix.elements()[i][j] = NAN;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue