diff options
author | Mike Reed <reed@google.com> | 2018-03-19 12:28:49 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-03-19 16:53:25 +0000 |
commit | 8430eace0bbf7258b25e42f289b6a63f38b075e7 (patch) | |
tree | 22d4d6e3f37d2a417656f1d74e9eff507d88b6d9 /src/core/SkPaint.cpp | |
parent | c683dd12fea07a99879a8ef5961a40a57029323b (diff) |
handle divide by zero in paint
Bug: oss-fuzz:7003
Change-Id: Ie3266292ca94a28cc7023ed5255895d25f0d4dc8
Reviewed-on: https://skia-review.googlesource.com/115041
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Diffstat (limited to 'src/core/SkPaint.cpp')
-rw-r--r-- | src/core/SkPaint.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index b54b8dfcdb..062c7ccbc4 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -1735,8 +1735,12 @@ SkTextBaseIter::SkTextBaseIter(const char text[], size_t length, if (fPaint.getPathEffect() == nullptr) { fPaint.setTextSize(SkIntToScalar(SkPaint::kCanonicalTextSizeForPaths)); fScale = paint.getTextSize() / SkPaint::kCanonicalTextSizeForPaths; + // Note: fScale can be zero here (even if it wasn't before the divide). It can also + // be very very small. We call sk_ieee_float_divide below to ensure IEEE divide behavior, + // since downstream we will check for the resulting coordinates being non-finite anyway. + // Thus we don't need to check for zero here. if (has_thick_frame(fPaint)) { - fPaint.setStrokeWidth(fPaint.getStrokeWidth() / fScale); + fPaint.setStrokeWidth(sk_ieee_float_divide(fPaint.getStrokeWidth(), fScale)); } } else { fScale = SK_Scalar1; |