| 23 | } |
| 24 | |
| 25 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) |
| 26 | { |
| 27 | // Force a valid "RIFF....WAVE" header so mutations reach the chunk walk + |
| 28 | // WAVEFORMATEX + sample read instead of bouncing at the RIFF/WAVE fourcc check. |
| 29 | static const uint8_t HDR[] = {'R', 'I', 'F', 'F', 0, 0, 0, 0, 'W', 'A', 'V', 'E'}; |
| 30 | std::vector<uint8_t> buf = fuzz::ForceHeader(HDR, sizeof(HDR), data, size); |
| 31 | try |
| 32 | { |
| 33 | WaveStream* ws = SoundLoadMemory(buf.data(), buf.size(), ".wav"); |
| 34 | if (ws) |
| 35 | { |
| 36 | WAVEFORMATEX fmt; |
| 37 | ws->GetFormat(fmt); |
| 38 | int total = ws->GetUncompressedSize(); |
| 39 | int cap = (total < 0) ? 0 : std::min(total, 16 << 20); // bound the decoded read |
| 40 | std::vector<char> buf(4096); |
| 41 | for (int off = 0; off < cap; off += static_cast<int>(buf.size())) |
| 42 | { |
| 43 | ws->GetData(buf.data(), off, std::min(static_cast<int>(buf.size()), cap - off)); |
| 44 | } |
| 45 | delete ws; |
| 46 | } |
| 47 | } |
| 48 | catch (...) |
| 49 | { |
| 50 | } |
| 51 | return 0; |
| 52 | } |
nothing calls this directly
no test coverage detected