Files
libwebp/tests/fuzzer/dec_fuzzer.cc
clang-format 44257cb826 apply clang-format
(Debian clang-format version 19.1.7 (3+build4)) with `--style=Google`.

Manual changes:
* clang-format disabled around macros with stringification (mostly
  assembly)
* some inline assembly strings were adjusted to avoid awkward line
  breaks
* trailing commas, `//` or suffixes (`ull`) added to help array
  formatting
* thread_utils.c: parameter comments were changed to the more common
  /*...=*/ style to improve formatting

The automatically generated code under swig/ was skipped.

Bug: 433996651
Change-Id: Iea3f24160d78d2a2653971cdf13fa932e47ff1b3
2025-07-31 14:53:58 -07:00

49 lines
1.6 KiB
C++

// Copyright 2024 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <string_view>
#include "src/webp/decode.h"
#include "tests/fuzzer/fuzz_utils.h"
namespace {
void DecodeWebP(std::string_view arbitrary_bytes) {
WebPDecoderConfig decoder_config;
if (!WebPInitDecoderConfig(&decoder_config)) {
fprintf(stderr, "WebPInitDecoderConfig failed.\n");
std::abort();
}
const VP8StatusCode status =
WebPDecode(reinterpret_cast<const uint8_t*>(arbitrary_bytes.data()),
arbitrary_bytes.size(), &decoder_config);
WebPFreeDecBuffer(&decoder_config.output);
// The decoding may fail (because the fuzzed input can be anything) but not
// for these reasons.
if (status == VP8_STATUS_SUSPENDED || status == VP8_STATUS_USER_ABORT) {
std::abort();
}
}
FUZZ_TEST(WebPSuite, DecodeWebP)
.WithDomains(fuzztest::String().WithMaxSize(fuzz_utils::kMaxWebPFileSize +
1));
} // namespace