diff options
author | Jim Van Verth <jvanverth@google.com> | 2018-06-19 15:00:28 -0400 |
---|---|---|
committer | Kevin Lubick <kjlubick@google.com> | 2018-06-19 19:36:49 +0000 |
commit | 796bc1db0ef1600ed8d2e7206642306982210055 (patch) | |
tree | 1c9b8052d209e5212d27bd1cae03e4eeb8f1bed8 /src | |
parent | 99ca453634e66c570c8b28fa188bb427edda848b (diff) |
Limit iterations when computing convex inset.
In the worst case we should compare each vertex in the polygon
to the others just once, so we should have at worst n^2 iterations.
Bug: skia:8079
Change-Id: Ic22064e86d6eb08d9165b2feb5050701ec8e9639
Reviewed-on: https://skia-review.googlesource.com/135865
Auto-Submit: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Diffstat (limited to 'src')
-rwxr-xr-x | src/utils/SkOffsetPolygon.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/utils/SkOffsetPolygon.cpp b/src/utils/SkOffsetPolygon.cpp index b335a25f0a..81b692f1bf 100755 --- a/src/utils/SkOffsetPolygon.cpp +++ b/src/utils/SkOffsetPolygon.cpp @@ -308,7 +308,13 @@ bool SkInsetConvexPolygon(const SkPoint* inputPolygonVerts, int inputPolygonSize int prevIndex = inputPolygonSize - 1; int currIndex = 0; int insetVertexCount = inputPolygonSize; + int iterations = 0; while (prevIndex != currIndex) { + ++iterations; + if (iterations > inputPolygonSize*inputPolygonSize) { + return false; + } + if (!edgeData[prevIndex].fValid) { prevIndex = (prevIndex + inputPolygonSize - 1) % inputPolygonSize; continue; |