diff options
author | Mike Reed <reed@google.com> | 2018-05-11 17:10:40 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-11 21:49:17 +0000 |
commit | 3202ac4d24de417a69c2557a37e5e1b5f70667e0 (patch) | |
tree | e5a2cff74096cf0ea62f6b6e58bf9a9c0bcb1f56 /src/core/SkPathPriv.h | |
parent | e6bbae787db50ca79f063213a72797ffc89c6557 (diff) |
Revert "Revert "reject large paths to avoid potential float overflows""
This reverts commit b8f0709aac43cfdefdbf3a307f8c2ecfc0c55d27.
Attempted fix: update the iData before we return.
Bug: oss-fuzz:8131
Change-Id: If60b8b45df4dcb1deecc18f58cb09644aaa3231d
Reviewed-on: https://skia-review.googlesource.com/127501
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src/core/SkPathPriv.h')
-rw-r--r-- | src/core/SkPathPriv.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/core/SkPathPriv.h b/src/core/SkPathPriv.h index 3ee1f83d06..9190962962 100644 --- a/src/core/SkPathPriv.h +++ b/src/core/SkPathPriv.h @@ -222,6 +222,28 @@ public: static bool IsBadForDAA(const SkPath& path) { return path.fIsBadForDAA; } static void SetIsBadForDAA(SkPath& path, bool isBadForDAA) { path.fIsBadForDAA = isBadForDAA; } + /** + * Sometimes in the drawing pipeline, we have to perform math on path coordinates, even after + * the path is in device-coordinates. Tessellation and clipping are two examples. Usually this + * is pretty modest, but it can involve subtracting/adding coordinates, or multiplying by + * small constants (e.g. 2,3,4). To try to preflight issues where these optionations could turn + * finite path values into infinities (or NaNs), we allow the upper drawing code to reject + * the path if its bounds (in device coordinates) is too close to max float. + */ + static bool TooBigForMath(const SkRect& bounds) { + // This value is just a guess. smaller is safer, but we don't want to reject largish paths + // that we don't have to. + constexpr SkScalar scale_down_to_allow_for_small_multiplies = 0.25f; + constexpr SkScalar max = SK_ScalarMax * scale_down_to_allow_for_small_multiplies; + + // use ! expression so we return true if bounds contains NaN + return !(bounds.fLeft >= -max && bounds.fTop >= -max && + bounds.fRight <= max && bounds.fBottom <= max); + } + static bool TooBigForMath(const SkPath& path) { + return TooBigForMath(path.getBounds()); + } + // Returns number of valid points for each SkPath::Iter verb static int PtsInIter(unsigned verb) { static const uint8_t gPtsInVerb[] = { |