1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 18:20:43 +09:00
ladybird/Meta/Lagom/Fuzzers/FuzzQOALoader.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
826 B
C++

/*
* Copyright (c) 2023, kleines Filmröllchen <filmroellchen@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/MemoryStream.h>
#include <LibAudio/QOALoader.h>
#include <stddef.h>
#include <stdint.h>
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
{
auto const qoa_bytes = ByteBuffer::copy(data, size).release_value();
auto qoa_data = try_make<FixedMemoryStream>(qoa_bytes).release_value();
auto qoa_or_error = Audio::QOALoaderPlugin::create(move(qoa_data));
if (qoa_or_error.is_error())
return 0;
auto qoa = qoa_or_error.release_value();
for (;;) {
auto samples = qoa->load_chunks(5 * KiB);
if (samples.is_error())
return 0;
if (samples.value().size() == 0)
break;
}
return 0;
}