mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-23 16:43:50 +00:00
added libraries: opus flac libsndfile updated: libvorbis libogg openal - Everything works as expected for now. Bare in mind libsndfile needed the check for whether or not it could find the xiph libraries removed in order for this to work.
79 lines
2.2 KiB
C++
79 lines
2.2 KiB
C++
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/types.h>
|
|
#include <sndfile.h>
|
|
#include <inttypes.h>
|
|
|
|
#include "sndfile_fuzz_header.h"
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
|
{ // One byte is needed for deciding which function to target.
|
|
if (size == 0)
|
|
return 0 ;
|
|
|
|
const uint8_t decider = *data ;
|
|
data += 1 ;
|
|
size -= 1 ;
|
|
|
|
SF_INFO sndfile_info ;
|
|
VIO_DATA vio_data ;
|
|
SF_VIRTUAL_IO vio ;
|
|
SNDFILE *sndfile = NULL ;
|
|
int err = sf_init_file(data, size, &sndfile, &vio_data, &vio, &sndfile_info) ;
|
|
if (err)
|
|
goto EXIT_LABEL ;
|
|
|
|
// Just the right number of channels. Create some buffer space for reading.
|
|
switch (decider % 3)
|
|
{ case 0 :
|
|
{
|
|
short* read_buffer = NULL ;
|
|
read_buffer = (short*)malloc(sizeof(short) * size);
|
|
if (read_buffer == NULL)
|
|
abort() ;
|
|
|
|
while (sf_read_short(sndfile, read_buffer, size))
|
|
{
|
|
// Do nothing with the data.
|
|
}
|
|
free(read_buffer) ;
|
|
}
|
|
break ;
|
|
case 1 :
|
|
{
|
|
int* read_buffer = NULL ;
|
|
read_buffer = (int*)malloc(sizeof(int) * size) ;
|
|
if (read_buffer == NULL)
|
|
abort() ;
|
|
|
|
while (sf_read_int(sndfile, read_buffer, size))
|
|
{
|
|
// Do nothing with the data.
|
|
}
|
|
free(read_buffer) ;
|
|
}
|
|
break ;
|
|
case 2 :
|
|
{
|
|
double* read_buffer = NULL ;
|
|
read_buffer = (double*)malloc(sizeof(double) * size) ;
|
|
if (read_buffer == NULL)
|
|
abort() ;
|
|
|
|
while (sf_read_double(sndfile, read_buffer, size))
|
|
{
|
|
// Do nothing with the data.
|
|
}
|
|
free(read_buffer) ;
|
|
}
|
|
break ;
|
|
default :
|
|
break ;
|
|
} ;
|
|
|
|
EXIT_LABEL:
|
|
if (sndfile != NULL)
|
|
sf_close(sndfile);
|
|
|
|
return 0 ;
|
|
}
|