mirror of
https://github.com/lighttransport/tinyusdz.git
synced 2026-01-18 01:11:17 +01:00
Add dr_wav decoder fuzzer
This commit is contained in:
31
tests/fuzzer/dr_wav_decoding_fuzzmain.cc
Normal file
31
tests/fuzzer/dr_wav_decoding_fuzzmain.cc
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <cstdint>
|
||||
|
||||
#define DR_WAV_IMPLEMENTATION
|
||||
#include "external/dr_wav.h"
|
||||
|
||||
static int parse_wav(const uint8_t* data, size_t size) {
|
||||
if (size > 1024 * 1024 * 128 * 4) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t channels;
|
||||
uint32_t sampleRate;
|
||||
drwav_uint64 totalFrameCount;
|
||||
|
||||
float* psampledata = drwav_open_memory_and_read_pcm_frames_f32(
|
||||
data, size, &channels, &sampleRate, &totalFrameCount, /* alloc callbacks */nullptr);
|
||||
|
||||
if (!data) {
|
||||
// err
|
||||
return 0;
|
||||
}
|
||||
|
||||
drwav_free(psampledata, /* alloc callbacks */nullptr );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(std::uint8_t const* data,
|
||||
std::size_t size) {
|
||||
return parse_wav(data, size);
|
||||
}
|
||||
@@ -101,3 +101,10 @@ executable('fuzz_dr_mp3_decoding',
|
||||
include_directories : incdirs,
|
||||
cpp_args : ['-fsanitize=address,fuzzer', '-DTINYUSDZ_FUZZER_BUILD=1'],
|
||||
link_args : '-fsanitize=address,fuzzer' )
|
||||
|
||||
executable('fuzz_dr_wav_decoding',
|
||||
'dr_wav_decoding_fuzzmain.cc',
|
||||
install: true,
|
||||
include_directories : incdirs,
|
||||
cpp_args : ['-fsanitize=address,fuzzer', '-DTINYUSDZ_FUZZER_BUILD=1'],
|
||||
link_args : '-fsanitize=address,fuzzer' )
|
||||
|
||||
Reference in New Issue
Block a user