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>
This commit is contained in:
Mike Reed 2018-03-19 12:28:49 -04:00 committed by Skia Commit-Bot
parent c683dd12fe
commit 8430eace0b

View File

@ -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;