1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 17:44:56 +09:00
ladybird/Meta/Lagom/Fuzzers/FuzzWAVLoader.cpp
kleines Filmröllchen 5f1dbbaaa6 LibAudio: Extract loader stream creation from the plugins
This removes a lot of duplicated stream creation code from the plugins,
and also simplifies the way that the appropriate plugin is found. This
mirrors the ImageDecoderPlugin design and necessitates new sniffing
methods on the loaders.
2023-06-27 15:28:22 +01:00

32 lines
800 B
C++

/*
* Copyright (c) 2021, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/MemoryStream.h>
#include <LibAudio/WavLoader.h>
#include <stddef.h>
#include <stdint.h>
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
{
auto const wav_bytes = ByteBuffer::copy(data, size).release_value();
auto wav_data = try_make<FixedMemoryStream>(wav_bytes).release_value();
auto wav_or_error = Audio::WavLoaderPlugin::create(move(wav_data));
if (wav_or_error.is_error())
return 0;
auto wav = wav_or_error.release_value();
for (;;) {
auto samples = wav->load_chunks(4 * KiB);
if (samples.is_error())
return 0;
if (samples.value().size() == 0)
break;
}
return 0;
}