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

Unified Diff: src/codec/SkBmpCodec.cpp

Issue 1498923002: Fix overflow caught by ASAN. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkBmpCodec.cpp
diff --git a/src/codec/SkBmpCodec.cpp b/src/codec/SkBmpCodec.cpp
index 191c2ad8009cbc39e713a2a56452e632a7e84012..2e9eca9fe49714fe665af6f6d8c96a18d3d07823 100644
--- a/src/codec/SkBmpCodec.cpp
+++ b/src/codec/SkBmpCodec.cpp
@@ -554,7 +554,7 @@ int32_t SkBmpCodec::getDstRow(int32_t y, int32_t height) const {
uint32_t SkBmpCodec::computeNumColors(uint32_t numColors) {
// Zero is a default for maxColors
// Also set numColors to maxColors when it is too large
- uint32_t maxColors = 1 << fBitsPerPixel;
+ uint32_t maxColors = fBitsPerPixel >= 32 ? UINT32_MAX : 1 << fBitsPerPixel;
msarett 2015/12/03 20:55:22 Can we use 0 instead of UINT32_MAX? While you're
if (numColors == 0 || numColors >= maxColors) {
return maxColors;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698