Check FuzzTest generated input length
Change-Id: Ie1160d5171c16fcccf8f7aece899feab38c6b19f
Reviewed-on: https://chromium-review.googlesource.com/c/codecs/libwebp2/+/5771353
Tested-by: WebM Builds <builds@webmproject.org>
Reviewed-by: Maryla Ustarroz-Calonge <maryla@google.com>
diff --git a/tests/fuzz/fuzztest_anim_and_enc_config.cc b/tests/fuzz/fuzztest_anim_and_enc_config.cc
index 1f672de..a8b14d1 100644
--- a/tests/fuzz/fuzztest_anim_and_enc_config.cc
+++ b/tests/fuzz/fuzztest_anim_and_enc_config.cc
@@ -24,6 +24,7 @@
#include "src/wp2/base.h"
#include "src/wp2/encode.h"
#include "src/wp2/format_constants.h"
+#include "gtest/gtest.h"
#include "fuzzing/fuzztest.h"
#include "tests/fuzz/fuzz_utils.h"
#include "tests/include/helpers.h"
@@ -75,6 +76,10 @@
uint8_t* samples = const_cast<uint8_t*>(frames_and_durations.samples.data());
const uint32_t stride =
WP2FormatBpp(frames_and_durations.format) * frames_and_durations.width;
+ // Make sure the fuzzer generates enough samples as described by the domains
+ // below (b/358211151).
+ ASSERT_GE(frames_and_durations.samples.size(),
+ stride * frames_and_durations.height * num_frames);
original_frames.reserve(num_frames);
for (size_t i = 0; i < num_frames; ++i) {