Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Issue 1504933002: Fix up signed-integer-overflow warnings (Closed)

Created:
5 years ago by tomhudson
Modified:
5 years ago
Reviewers:
mtklein, reed1
CC:
reviews_skia.org
Base URL:
https://skia.googlesource.com/skia.git@master
Target Ref:
refs/heads/master
Project:
skia
Visibility:
Public.

Description

Fix up signed-integer-overflow warnings When checking whether a matrix was a pure scale, we subtracted 0x3f800000 from the diagonals; if the diagonal value was already very negative, we'd underflow. Replace subtraction with XOR. When dealing with repeating tiled bitmaps, when the bitmap was very large, we'd multiply an offset by 65535, possibly causing underflow. Throw in a cast to long (casting to unsigned also silences the warning and wouldn't involve extension, but I can't convince myself that it's correct). BUG=skia:4635 R=mtklein@google.com Committed: https://skia.googlesource.com/skia/+/d5c4265b49d212f7888d0516328f39c4d45d3058

Patch Set 1 #

Total comments: 1

Patch Set 2 : reed@'s verbal review #

Unified diffs Side-by-side diffs Delta from patch set Stats (+9 lines, -7 lines) Patch
M src/core/SkBitmapProcState_matrixProcs.cpp View 1 1 chunk +8 lines, -6 lines 0 comments Download
M src/core/SkMatrix.cpp View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 10 (3 generated)
tomhudson
There were only a couple of signed-integer-overflow warnings in the codebase. PTAL?
5 years ago (2015-12-07 17:55:17 UTC) #1
mtklein
https://codereview.chromium.org/1504933002/diff/1/src/core/SkBitmapProcState_matrixProcs.cpp File src/core/SkBitmapProcState_matrixProcs.cpp (right): https://codereview.chromium.org/1504933002/diff/1/src/core/SkBitmapProcState_matrixProcs.cpp#newcode106 src/core/SkBitmapProcState_matrixProcs.cpp:106: return SK_USHIFT16((long)((fx) & 0xFFFF) * ((max) + 1)); Let's ...
5 years ago (2015-12-07 17:58:16 UTC) #2
tomhudson
Drew back to (unsigned), in more places, and added some SkASSERT()s as reed@ suggested. Now ...
5 years ago (2015-12-07 18:17:23 UTC) #4
mtklein
lgtm
5 years ago (2015-12-07 18:19:22 UTC) #5
reed1
possibly we could try to share the expression in the bitmapshader, between the macros and ...
5 years ago (2015-12-07 18:21:48 UTC) #6
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1504933002/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1504933002/20001
5 years ago (2015-12-07 18:22:23 UTC) #8
commit-bot: I haz the power
5 years ago (2015-12-07 18:38:07 UTC) #10
Message was sent while issue was closed.
Committed patchset #2 (id:20001) as
https://skia.googlesource.com/skia/+/d5c4265b49d212f7888d0516328f39c4d45d3058

Powered by Google App Engine
This is Rietveld 408576698