if (isIco) {
height /= 2;
}
- static const int kBmpMaxDim = 1 << 16;
- if (width < 0 || width >= kBmpMaxDim || height >= kBmpMaxDim) {
- // TODO: Decide if we want to support really large bmps.
+ if (width <= 0 || height <= 0) {
+ // TODO: Decide if we want to disable really large bmps as well.
+ // https://code.google.com/p/skia/issues/detail?id=3617
SkCodecPrintf("Error: invalid bitmap dimensions.\n");
return false;
}
test_dimensions(r, "randPixels.jpg");
}
+static void test_empty(skiatest::Reporter* r, const char path[]) {
+ SkAutoTDelete<SkStream> stream(resource(path));
+ if (!stream) {
+ SkDebugf("Missing resource '%s'\n", path);
+ return;
+ }
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach()));
+ REPORTER_ASSERT(r, NULL == codec);
+}
-
+DEF_TEST(Codec_Empty, r) {
+ // Test images that should not be able to create a codec
+ test_empty(r, "empty_images/zero-dims.gif");
+ test_empty(r, "empty_images/zero-embedded.ico");
+ test_empty(r, "empty_images/zero-width.bmp");
+ test_empty(r, "empty_images/zero-height.bmp");
+ test_empty(r, "empty_images/zero-width.jpg");
+ test_empty(r, "empty_images/zero-height.jpg");
+ test_empty(r, "empty_images/zero-width.png");
+ test_empty(r, "empty_images/zero-height.png");
+ test_empty(r, "empty_images/zero-width.wbmp");
+ test_empty(r, "empty_images/zero-height.wbmp");
+}