Don't do PolyUtil fuzz tests on invalid polygons.
We shouldn't be trying to run the convex routine on known non-convex polygons, and the offset routine only works for simple polygons. Bug: oss-fuzz:43588 Change-Id: Ia1c73d05d7b1496c9d0599ee36eafe1d58684fd6 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/494818 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
parent
dd9e165ef7
commit
1f0e64acd6
@ -32,22 +32,26 @@ DEF_FUZZ(PolyUtils, fuzz) {
|
||||
bounds.setBoundsCheck(polygon, count);
|
||||
|
||||
ignoreResult(SkGetPolygonWinding(polygon, count));
|
||||
ignoreResult(SkIsConvexPolygon(polygon, count));
|
||||
ignoreResult(SkIsSimplePolygon(polygon, count));
|
||||
bool isConvex = SkIsConvexPolygon(polygon, count);
|
||||
bool isSimple = SkIsSimplePolygon(polygon, count);
|
||||
|
||||
SkScalar inset;
|
||||
fuzz->next(&inset);
|
||||
SkTDArray<SkPoint> output;
|
||||
ignoreResult(SkInsetConvexPolygon(polygon, count, inset, &output));
|
||||
|
||||
SkScalar offset;
|
||||
fuzz->next(&offset);
|
||||
ignoreResult(SkOffsetSimplePolygon(polygon, count, bounds, offset, &output));
|
||||
|
||||
SkAutoSTMalloc<64, uint16_t> indexMap(count);
|
||||
for (int index = 0; index < count; ++index) {
|
||||
fuzz->next(&indexMap[index]);
|
||||
if (isConvex) {
|
||||
SkScalar inset;
|
||||
fuzz->next(&inset);
|
||||
ignoreResult(SkInsetConvexPolygon(polygon, count, inset, &output));
|
||||
}
|
||||
|
||||
if (isSimple) {
|
||||
SkScalar offset;
|
||||
fuzz->next(&offset);
|
||||
ignoreResult(SkOffsetSimplePolygon(polygon, count, bounds, offset, &output));
|
||||
|
||||
SkAutoSTMalloc<64, uint16_t> indexMap(count);
|
||||
for (int index = 0; index < count; ++index) {
|
||||
fuzz->next(&indexMap[index]);
|
||||
}
|
||||
SkTDArray<uint16_t> outputIndices;
|
||||
ignoreResult(SkTriangulateSimplePolygon(polygon, indexMap, count, &outputIndices));
|
||||
}
|
||||
SkTDArray<uint16_t> outputIndices;
|
||||
ignoreResult(SkTriangulateSimplePolygon(polygon, indexMap, count, &outputIndices));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user