diff options
author | fmalita <fmalita@chromium.org> | 2016-05-26 18:10:24 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-26 18:10:24 -0700 |
commit | 7dcb131935bda4aada0e37085c9f5e1f6a8f3842 (patch) | |
tree | c3357fb17d0a80d7b9092973f37f69ca8bc4436e /src/effects/gradients | |
parent | b8486f5092ec3c0760a08ff1ecf76ad601b8609d (diff) |
Silence ASAN int32 overflow warning
It's fine to overflow SK_MaxS32 by one, the subsequent cast ensures
correct clamping. But we need to cast earlier in order to make ASAN
happy.
TBR=mtklein@google.com,reed@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2013243002
Review-Url: https://codereview.chromium.org/2013243002
Diffstat (limited to 'src/effects/gradients')
-rw-r--r-- | src/effects/gradients/SkLinearGradient.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp index 209b833973..7752aac51d 100644 --- a/src/effects/gradients/SkLinearGradient.cpp +++ b/src/effects/gradients/SkLinearGradient.cpp @@ -612,7 +612,8 @@ void SkLinearGradient::LinearGradientContext::shade4_dx_clamp(SkPMColor dstC[], if (fx < 0) { // count is guaranteed to be positive, but the first arg may overflow int32 after // increment => casting to uint32 ensures correct clamping. - int n = SkTMin<uint32_t>(SkFloatToIntFloor(-fx * invDx) + 1, count); + int n = SkTMin<uint32_t>(static_cast<uint32_t>(SkFloatToIntFloor(-fx * invDx)) + 1, + count); SkASSERT(n > 0); fill<apply_alpha>(dstC, n, rec[0].fColor); count -= n; @@ -627,7 +628,8 @@ void SkLinearGradient::LinearGradientContext::shade4_dx_clamp(SkPMColor dstC[], if (fx > 1) { // count is guaranteed to be positive, but the first arg may overflow int32 after // increment => casting to uint32 ensures correct clamping. - int n = SkTMin<uint32_t>(SkFloatToIntFloor((1 - fx) * invDx) + 1, count); + int n = SkTMin<uint32_t>(static_cast<uint32_t>(SkFloatToIntFloor((1 - fx) * invDx)) + 1, + count); SkASSERT(n > 0); fill<apply_alpha>(dstC, n, rec[fRecs.count() - 1].fColor); count -= n; |