diff options
author | caryclark <caryclark@google.com> | 2015-12-09 12:02:30 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-09 12:02:30 -0800 |
commit | 3127c99986dc932343aae5ccc575237d99c3aaec (patch) | |
tree | 68b3bf28a8f38c10838afa7a2b28478ad07ff17f /src/core/SkUtils.cpp | |
parent | e36ec871768eb4f5372540c1167ff7ec592f2bec (diff) |
ubsan shift fixes
Use an inline function that does a normal shift. When built for the sanitizer, add casts so that the shift is unsigned.
Also make a few fixes to do unsigned shifts or avoid the shift altogether; and add an argument spec to some macros.
R=reed@google.com,mtklein@google.com
BUG=skia:4633
Review URL: https://codereview.chromium.org/1503423003
Diffstat (limited to 'src/core/SkUtils.cpp')
-rw-r--r-- | src/core/SkUtils.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/core/SkUtils.cpp b/src/core/SkUtils.cpp index b3f698b4e7..f706cb9f25 100644 --- a/src/core/SkUtils.cpp +++ b/src/core/SkUtils.cpp @@ -74,11 +74,11 @@ SkUnichar SkUTF8_ToUnichar(const char utf8[]) { if (hic < 0) { uint32_t mask = (uint32_t)~0x3F; - hic <<= 1; + hic = SkLeftShift(hic, 1); do { c = (c << 6) | (*++p & 0x3F); mask <<= 5; - } while ((hic <<= 1) < 0); + } while ((hic = SkLeftShift(hic, 1)) < 0); c &= ~mask; } return c; @@ -95,11 +95,11 @@ SkUnichar SkUTF8_NextUnichar(const char** ptr) { if (hic < 0) { uint32_t mask = (uint32_t)~0x3F; - hic <<= 1; + hic = SkLeftShift(hic, 1); do { c = (c << 6) | (*++p & 0x3F); mask <<= 5; - } while ((hic <<= 1) < 0); + } while ((hic = SkLeftShift(hic, 1)) < 0); c &= ~mask; } *ptr = (char*)p + 1; |