summaryrefslogtreecommitdiff
path: root/Meta
diff options
context:
space:
mode:
authorTim Schumacher <timschumi@gmx.de>2022-12-05 00:41:23 +0100
committerAndreas Kling <kling@serenityos.org>2022-12-05 17:49:47 +0100
commitc57be0f47496d2bb23da25224833f9080f9cbcc4 (patch)
treed30a8762aece6a79167c1fcf7e6ef2a1223e4038 /Meta
parent3cf93d0dd2377b3ce85362db05e47a373006a56e (diff)
downloadserenity-c57be0f47496d2bb23da25224833f9080f9cbcc4.zip
LibAudio: Switch LoaderPlugin to a more traditional constructor pattern
This now prepares all the needed (fallible) components before actually constructing a LoaderPlugin object, so we are no longer filling them in at an arbitrary later point in time.
Diffstat (limited to 'Meta')
-rw-r--r--Meta/Lagom/Fuzzers/FuzzFlacLoader.cpp8
-rw-r--r--Meta/Lagom/Fuzzers/FuzzMP3Loader.cpp8
-rw-r--r--Meta/Lagom/Fuzzers/FuzzWAVLoader.cpp7
3 files changed, 16 insertions, 7 deletions
diff --git a/Meta/Lagom/Fuzzers/FuzzFlacLoader.cpp b/Meta/Lagom/Fuzzers/FuzzFlacLoader.cpp
index 5056f0899e..2f393e0c3b 100644
--- a/Meta/Lagom/Fuzzers/FuzzFlacLoader.cpp
+++ b/Meta/Lagom/Fuzzers/FuzzFlacLoader.cpp
@@ -11,10 +11,12 @@
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
{
auto flac_data = ByteBuffer::copy(data, size).release_value();
- auto flac = make<Audio::FlacLoaderPlugin>(flac_data.bytes());
+ auto flac_or_error = Audio::FlacLoaderPlugin::try_create(flac_data.bytes());
- if (flac->initialize().is_error())
- return 1;
+ if (flac_or_error.is_error())
+ return 0;
+
+ auto flac = flac_or_error.release_value();
for (;;) {
auto samples = flac->get_more_samples();
diff --git a/Meta/Lagom/Fuzzers/FuzzMP3Loader.cpp b/Meta/Lagom/Fuzzers/FuzzMP3Loader.cpp
index 4d1b751e57..a3f9ba90cb 100644
--- a/Meta/Lagom/Fuzzers/FuzzMP3Loader.cpp
+++ b/Meta/Lagom/Fuzzers/FuzzMP3Loader.cpp
@@ -11,10 +11,12 @@
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
{
auto flac_data = ByteBuffer::copy(data, size).release_value();
- auto mp3 = make<Audio::MP3LoaderPlugin>(flac_data.bytes());
+ auto mp3_or_error = Audio::MP3LoaderPlugin::try_create(flac_data.bytes());
- if (mp3->initialize().is_error())
- return 1;
+ if (mp3_or_error.is_error())
+ return 0;
+
+ auto mp3 = mp3_or_error.release_value();
for (;;) {
auto samples = mp3->get_more_samples();
diff --git a/Meta/Lagom/Fuzzers/FuzzWAVLoader.cpp b/Meta/Lagom/Fuzzers/FuzzWAVLoader.cpp
index e668ff317b..8e589b21b7 100644
--- a/Meta/Lagom/Fuzzers/FuzzWAVLoader.cpp
+++ b/Meta/Lagom/Fuzzers/FuzzWAVLoader.cpp
@@ -13,7 +13,12 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
if (!data)
return 0;
auto wav_data = ReadonlyBytes { data, size };
- auto wav = make<Audio::WavLoaderPlugin>(wav_data);
+ auto wav_or_error = Audio::WavLoaderPlugin::try_create(wav_data);
+
+ if (wav_or_error.is_error())
+ return 0;
+
+ auto wav = wav_or_error.release_value();
for (;;) {
auto samples = wav->get_more_samples();