| Index: tests/CodexTest.cpp
|
| diff --git a/tests/CodexTest.cpp b/tests/CodexTest.cpp
|
| index 697ba749f70861d9678a19894622dff8ec1ed8bf..99a363f53e671eaf8c4be3713226ec60fc249023 100644
|
| --- a/tests/CodexTest.cpp
|
| +++ b/tests/CodexTest.cpp
|
| @@ -877,3 +877,32 @@ DEF_TEST(Codec_wbmp, r) {
|
| }
|
| test_info(r, codec, codec->getInfo(), SkCodec::kSuccess, nullptr);
|
| }
|
| +
|
| +// wbmp images have a header that can be arbitrarily large, depending on the
|
| +// size of the image. We cap the size at 65535, meaning we only need to look at
|
| +// 8 bytes to determine whether we can read the image. This is important
|
| +// because SkCodec only passes 14 bytes to SkWbmpCodec to determine whether the
|
| +// image is a wbmp.
|
| +DEF_TEST(Codec_wbmp_max_size, r) {
|
| + const unsigned char maxSizeWbmp[] = { 0x00, 0x00, // Header
|
| + 0x83, 0xFF, 0x7F, // W: 65535
|
| + 0x83, 0xFF, 0x7F }; // H: 65535
|
| + SkAutoTDelete<SkStream> stream(new SkMemoryStream(maxSizeWbmp, sizeof(maxSizeWbmp), false));
|
| + SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach()));
|
| +
|
| + REPORTER_ASSERT(r, codec);
|
| + if (!codec) return;
|
| +
|
| + REPORTER_ASSERT(r, codec->getInfo().width() == 65535);
|
| + REPORTER_ASSERT(r, codec->getInfo().height() == 65535);
|
| +
|
| + // Now test an image which is too big. Any image with a larger header (i.e.
|
| + // has bigger width/height) is also too big.
|
| + const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header
|
| + 0x84, 0x80, 0x00, // W: 65536
|
| + 0x84, 0x80, 0x00 }; // H: 65536
|
| + stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false));
|
| + codec.reset(SkCodec::NewFromStream(stream.detach()));
|
| +
|
| + REPORTER_ASSERT(r, !codec);
|
| +}
|
|
|