handle extreme dashes

Make searching indices unsigned so intermediate middle
doesn't overflow. Verified fix runs test in skia:7675
successfully.

R=reed@google.com
Bug: skia:7675
Change-Id: I76be1d3fee8875ae9eb2b18eb070ef66c8006c03
Reviewed-on: https://skia-review.googlesource.com/114798
Reviewed-by: Cary Clark <caryclark@skia.org>
Commit-Queue: Cary Clark <caryclark@skia.org>
This commit is contained in:
Cary Clark 2018-03-16 14:59:12 -04:00 committed by Skia Commit-Bot
parent 486ee3d4c6
commit 9475aa0f90

View File

@ -528,11 +528,11 @@ int SkTKSearch(const T base[], int count, const K& key) {
SkASSERT(base != nullptr); // base may be nullptr if count is zero SkASSERT(base != nullptr); // base may be nullptr if count is zero
int lo = 0; unsigned lo = 0;
int hi = count - 1; unsigned hi = count - 1;
while (lo < hi) { while (lo < hi) {
int mid = (hi + lo) >> 1; unsigned mid = (hi + lo) >> 1;
if (base[mid].fDistance < key) { if (base[mid].fDistance < key) {
lo = mid + 1; lo = mid + 1;
} else { } else {