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
This commit is contained in:
parent
b8486f5092
commit
7dcb131935
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user