libretro / gambatte-libretro

Hard fork of Gambatte to the libretro API.
http://sourceforge.net/projects/gambatte/
GNU General Public License v2.0
105 stars 79 forks source link

Prevent segfaults due to audio buffer overflows #184

Closed jdgleaver closed 3 years ago

jdgleaver commented 3 years ago

While testing #183, I noticed that at least two GBC games cause Gambatte to generate a segfault (1942 and Alone in the Dark). This happens because the GB::runFor() function has an inaccurate description:

This PR simply makes the audio handling code aware of the input buffer size, and 'clips' the generated output in the event that an overflow would occur. There are no longer any segfaults, and both 1942 and Alone in the Dark now run correctly.