Improve AImageDecoder fuzzer
Bug: 169137236
Bug: 169139756
Test: this (fuzzer)
Extend the fuzzer to test animations.
Also test a lossless webp, left out of
Ib227639bf8da75f0e8e31e216bc6d1371e24cb75.
Change-Id: I81d35d6fa7d560b33b6a2b5d6c1992cbdd77bc87
diff --git a/native/graphics/jni/corpus/webp-color-profile-lossless.webp b/native/graphics/jni/corpus/webp-color-profile-lossless.webp
new file mode 100644
index 0000000..4fd63d5
--- /dev/null
+++ b/native/graphics/jni/corpus/webp-color-profile-lossless.webp
Binary files differ
diff --git a/native/graphics/jni/fuzz_imagedecoder.cpp b/native/graphics/jni/fuzz_imagedecoder.cpp
index f2cd1a8..015aca7 100644
--- a/native/graphics/jni/fuzz_imagedecoder.cpp
+++ b/native/graphics/jni/fuzz_imagedecoder.cpp
@@ -73,6 +73,12 @@
return 0;
}
- AImageDecoder_decodeImage(decoder.get(), pixels.get(), stride, pixelSize);
+ while (true) {
+ int result = AImageDecoder_decodeImage(decoder.get(), pixels.get(), stride, pixelSize);
+ if (result != ANDROID_IMAGE_DECODER_SUCCESS) break;
+
+ result = AImageDecoder_advanceFrame(decoder.get());
+ if (result != ANDROID_IMAGE_DECODER_SUCCESS) break;
+ }
return 0;
}