Potentially-uninitialized Sk3LookAt result

Bug: oss-fuzz:20520
Change-Id: I383881571fa156c6faa5e798a1e126bb9e5e8dd0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268621
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
Florin Malita 2020-02-04 10:06:24 -05:00 committed by Skia Commit-Bot
parent 4bcab23423
commit d589916ebc
4 changed files with 12 additions and 6 deletions

View File

@ -19,8 +19,10 @@ struct Info {
};
static SkM44 inv(const SkM44& m) {
SkM44 inverse;
m.invert(&inverse);
SkM44 inverse(SkM44::kUninitialized_Constructor);
if (!m.invert(&inverse)) {
inverse.setIdentity();
}
return inverse;
}

View File

@ -287,7 +287,7 @@ public:
/** If this is invertible, return that in inverse and return true. If it is
* not invertible, return false and leave the inverse parameter unchanged.
*/
bool invert(SkM44* inverse) const;
bool SK_WARN_UNUSED_RESULT invert(SkM44* inverse) const;
SkM44 transpose() const;

View File

@ -183,8 +183,10 @@ struct Face {
};
static bool front(const SkM44& m) {
SkM44 m2;
m.invert(&m2);
SkM44 m2(SkM44::kUninitialized_Constructor);
if (!m.invert(&m2)) {
m2.setIdentity();
}
/*
* Classically we want to dot the transpose(inverse(ctm)) with our surface normal.
* In this case, the normal is known to be {0, 0, 1}, so we only actually need to look

View File

@ -296,7 +296,9 @@ SkM44 Sk3LookAt(const SkV3& eye, const SkV3& center, const SkV3& up) {
SkV3 s = normalize(f.cross(u));
SkM44 m(SkM44::kUninitialized_Constructor);
(void)SkM44::Cols(v4(s, 0), v4(s.cross(f), 0), v4(-f, 0), v4(eye, 1)).invert(&m);
if (!SkM44::Cols(v4(s, 0), v4(s.cross(f), 0), v4(-f, 0), v4(eye, 1)).invert(&m)) {
m.setIdentity();
}
return m;
}