Coverage Report

Created: 2025-07-12 06:10

/src/libsndfile/ossfuzz/sndfile_fuzzer.cc
Line
Count
Source (jump to first uncovered line)
1
#include <stdint.h>
2
#include <stdlib.h>
3
#include <string.h>
4
#include <sys/types.h>
5
#include <sndfile.h>
6
#include <inttypes.h>
7
8
#include "sndfile_fuzz_header.h"
9
10
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
11
20.4k
{  VIO_DATA vio_data ;
12
20.4k
   SF_VIRTUAL_IO vio ;
13
20.4k
   SF_INFO sndfile_info ;
14
20.4k
   SNDFILE *sndfile = NULL ;
15
20.4k
   float* read_buffer = NULL ;
16
17
20.4k
   int err = sf_init_file(data, size, &sndfile, &vio_data, &vio, &sndfile_info) ;
18
20.4k
   if (err)
19
17.2k
     goto EXIT_LABEL ;
20
21
   // Just the right number of channels. Create some buffer space for reading.
22
3.20k
   read_buffer = (float*)malloc(sizeof(float) * sndfile_info.channels);
23
3.20k
   if (read_buffer == NULL)
24
0
     abort() ;
25
26
179M
   while (sf_readf_float(sndfile, read_buffer, 1))
27
179M
   {
28
     // Do nothing with the data.
29
179M
   }
30
31
20.4k
EXIT_LABEL:
32
33
20.4k
   if (sndfile != NULL)
34
3.20k
     sf_close(sndfile) ;
35
36
20.4k
   free(read_buffer) ;
37
38
20.4k
   return 0 ;
39
3.20k
}