Coverage Report

Created: 2026-09-14 07:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwebp/tests/fuzzer/anim_util_fuzzer.cc
Line
Count
Source
1
// Copyright 2026 Google Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//      http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
//
15
////////////////////////////////////////////////////////////////////////////////
16
17
#include <cstdint>
18
#include <cstdio>
19
#include <cstdlib>
20
#include <string_view>
21
22
#include "./fuzz_utils.h"
23
#include "./nalloc.h"
24
#include "examples/anim_util.h"
25
26
namespace {
27
28
6.03k
void ReadAnimatedImageTest(std::string_view blob) {
29
6.03k
  const uint8_t* const data = reinterpret_cast<const uint8_t*>(blob.data());
30
6.03k
  const size_t size = blob.size();
31
6.03k
  if (fuzz_utils::IsImageTooBig(data, size)) return;
32
33
5.93k
  nalloc_init(nullptr);
34
5.93k
  nalloc_start(data, size);
35
36
5.93k
  AnimatedImage image;
37
5.93k
  if (ReadAnimatedImageFromMemory("random_file", data, size, &image,
38
5.93k
                                  /*dump_frames=*/0, /*dump_folder=*/nullptr)) {
39
835
    ClearAnimatedImage(&image);
40
835
  }
41
42
5.93k
  nalloc_end();
43
5.93k
}
44
45
}  // namespace
46
47
FUZZ_TEST(ReadAnimatedImage, ReadAnimatedImageTest)
48
    .WithDomains(fuzztest::String().WithMaxSize(fuzz_utils::kMaxWebPFileSize +
49
                                                1));