aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/CodecTest.cpp
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2017-01-25 11:58:11 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-25 17:27:39 +0000
commit74b16edd98e4fd560baaf5655dd7e4ae43f8ae69 (patch)
tree982fa496c867d4574fcb7c1a8f8ac39e4db384f0 /tests/CodecTest.cpp
parent58abc9e2c56464336472493745e91133819deb96 (diff)
Add test for bad reuse of SkJpegCodec internal state
This is a test for the following fix: https://skia-review.googlesource.com/c/7451/ b/34637813 Change-Id: I3fdb0d7d50537948039b75c3a22454e789ca810a Reviewed-on: https://skia-review.googlesource.com/7454 Commit-Queue: Matt Sarett <msarett@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'tests/CodecTest.cpp')
-rw-r--r--tests/CodecTest.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index 8294c7a565..f0d60e78ea 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -1018,11 +1018,28 @@ DEF_TEST(Codec_jpeg_rewind, r) {
// Perform a sampled decode.
SkAndroidCodec::AndroidOptions opts;
opts.fSampleSize = 12;
- codec->getAndroidPixels(codec->getInfo().makeWH(width / 12, height / 12), pixelStorage.get(),
- rowBytes, &opts);
+ SkCodec::Result result = codec->getAndroidPixels(
+ codec->getInfo().makeWH(width / 12, height / 12), pixelStorage.get(), rowBytes, &opts);
+ REPORTER_ASSERT(r, SkCodec::kSuccess == result);
// Rewind the codec and perform a full image decode.
- SkCodec::Result result = codec->getPixels(codec->getInfo(), pixelStorage.get(), rowBytes);
+ result = codec->getPixels(codec->getInfo(), pixelStorage.get(), rowBytes);
+ REPORTER_ASSERT(r, SkCodec::kSuccess == result);
+
+ // Now perform a subset decode.
+ {
+ opts.fSampleSize = 1;
+ SkIRect subset = SkIRect::MakeWH(100, 100);
+ opts.fSubset = &subset;
+ result = codec->getAndroidPixels(codec->getInfo().makeWH(100, 100), pixelStorage.get(),
+ rowBytes, &opts);
+ REPORTER_ASSERT(r, SkCodec::kSuccess == result);
+ }
+
+ // Perform another full image decode. ASAN will detect if we look at the subset when it is
+ // out of scope. This would happen if we depend on the old state in the codec.
+ opts.fSubset = nullptr;
+ result = codec->getAndroidPixels(codec->getInfo(), pixelStorage.get(), rowBytes, &opts);
REPORTER_ASSERT(r, SkCodec::kSuccess == result);
}