8-bit stereo WAV files corrupt the heap (saturnringlib/srl_sound.hpp:680)

Open Beginner friendly
#146 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp

Research direction

The bug is in the stereo split loop in saturnringlib/srl_sound.hpp near line 680, which writes the right channel to data[dataSize + sample] and loops to dataSize/2. Read how dataSize and the buffer allocation are computed for 8-bit stereo WAVs, then check the index and loop bound against the real sample count. Done when a short 8-bit stereo WAV loads without writing past the buffer, which you can confirm with a small test file or a bounds-checking build.

Written by the indexing model from the issue text.

Description

bug required hardware test
  • What this is: The same loader splits stereo samples into a left half and a right half.
    • Problem: The right channel is written to data[dataSize + sample], which is past the end of the buffer. The loop also runs to dataSize/2, the padded size, so short files are read past their end.
    • Fix: Write to data[dataSize/2 + sample] and loop to size >> 1, the real sample count.
Dominant language
C++
Stars
90
Forks
5
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ReyeMe/SaturnRingLib

All issues in ReyeMe/SaturnRingLib

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.