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

Unified Diff: src/core/SkBitmap.cpp

Issue 122473002: ComputeRowBytes must not overflow width when it shifts (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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 | tests/BitmapTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmap.cpp
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 11c7cbd69c289991ea25c8894a6b62037ec34a2c..502d7db9b40c235b0865881b8acbb73e494019c2 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -190,10 +190,14 @@ size_t SkBitmap::ComputeRowBytes(Config c, int width) {
break;
case kRGB_565_Config:
case kARGB_4444_Config:
- rowBytes = width << 1;
+ // assign and then shift, so we don't overflow int
+ rowBytes = width;
+ rowBytes <<= 1;
break;
case kARGB_8888_Config:
- rowBytes = width << 2;
+ // assign and then shift, so we don't overflow int
+ rowBytes = width;
+ rowBytes <<= 2;
break;
default:
SkDEBUGFAIL("unknown config");
« no previous file with comments | « no previous file | tests/BitmapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698