jarikomppa / soloud

Free, easy, portable audio engine for games
http://soloud-audio.com
Other
1.69k stars 270 forks source link

WavStream::loadogg crashes due to unintended memory layout of File. #301

Open midn1 opened 3 years ago

midn1 commented 3 years ago

I updated my system and SoLoud::WavStream::load("assets/intro.ogg") had begun crashing. I tracked down the problem, and it's to do with the use of Soloud_Filehack in SoLoud::WavStream::loadogg. It seems to assume that the mFileHandle member comes first in memory, which it wasn't in my case (it was at offset 8).

I would fix this problem and PR, but honestly I have no idea how to fix this in a clean way. The fact this code existed at all is concerning. Turning (Soloud_Filehack*)fp into dynamic_cast<DiskFile*>(fp)->mFileHandle wouldn't be much better.

midn1 commented 3 years ago

include "soloud_file_hack_on.h"

Oh, so that's what's been happening. I had my own version of stb_vorbis.c without this. This is shameful.