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

Unified Diff: tests/BitmapTest.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 | « src/core/SkBitmap.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/BitmapTest.cpp
diff --git a/tests/BitmapTest.cpp b/tests/BitmapTest.cpp
index 250b6da32c2aa748db19d8996a6dfc3d2384ec06..aaa297e674570d2007149c8e805565897c6f4f21 100644
--- a/tests/BitmapTest.cpp
+++ b/tests/BitmapTest.cpp
@@ -10,6 +10,22 @@
#include "Test.h"
#include "TestClassDef.h"
+static void test_bigwidth(skiatest::Reporter* reporter) {
+ SkBitmap bm;
+ int width = 1 << 29; // *4 will be the high-bit of 32bit int
+
+ REPORTER_ASSERT(reporter, bm.setConfig(SkBitmap::kA8_Config, width, 1));
+ REPORTER_ASSERT(reporter, bm.setConfig(SkBitmap::kRGB_565_Config, width, 1));
+
+ // for a 4-byte config, this width will compute a rowbytes of 0x80000000,
+ // which does not fit in a int32_t. setConfig should detect this, and fail.
+
+ // TODO: perhaps skia can relax this, and only require that rowBytes fit
+ // in a uint32_t (or larger), but for now this is the constraint.
+
+ REPORTER_ASSERT(reporter, !bm.setConfig(SkBitmap::kARGB_8888_Config, width, 1));
+}
+
/**
* This test contains basic sanity checks concerning bitmaps.
*/
@@ -27,4 +43,6 @@ DEF_TEST(Bitmap, reporter) {
REPORTER_ASSERT(reporter, SkToBool(width & height) != bm.empty());
}
}
+
+ test_bigwidth(reporter);
}
« no previous file with comments | « src/core/SkBitmap.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698