Check for count == 0 when computing center of mass.

Bug: oss-fuzz:41243
Change-Id: I0297469057826f83ab35c43733ffb7d3cc5b9965
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/508679
Auto-Submit: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
Jim Van Verth 2022-02-14 15:20:09 -05:00 committed by SkCQ
parent b493da459e
commit c94eb30c6e

View File

@ -71,6 +71,9 @@ bool center_of_mass(const SegmentArray& segments, SkPoint* c) {
SkScalar area = 0;
SkPoint center = {0, 0};
int count = segments.count();
if (count <= 0) {
return false;
}
SkPoint p0 = {0, 0};
if (count > 2) {
// We translate the polygon so that the first point is at the origin.