mattiasgustavsson / dos-like

Engine for making things with a MS-DOS feel, but for modern platforms
Other
1k stars 49 forks source link

Fix memory corruption in app_sound_callback #11

Closed thp closed 3 years ago

thp commented 3 years ago

sample_pairs_count might be bigger than SOUND_BUFFER_SIZE (at least with SDL2 + Linux), leading to out-of-bounds access.

mattiasgustavsson commented 3 years ago

Hm, if sample_pairs_count is larger than SOUND_BUFFER_SIZE, I don't think changing just the memset would be enough - other parts of the code will both write and read out of bounds. I will look into it and see how to make it more robust.

mattiasgustavsson commented 3 years ago

Taking the lazy option for now, and just bumping up the buffer sizes. If you could try it and see if it fixes it, that would be great :)