RetroPie / EmulationStation

A Fork of Emulation Station for RetroPie. Emulation Station is a flexible emulator front-end supporting keyboardless navigation and custom system themes.
Other
856 stars 344 forks source link

Missing error checks for SDL_BuildAudioCVT #230

Open ChliHug opened 7 years ago

ChliHug commented 7 years ago

When Sound::init calls SDL_BuildAudioCVT it doesn't check for errors and then tries to allocate memory based on values that the function was supposed to set. This can have obvious memory allocation failures and other issues.

https://github.com/RetroPie/EmulationStation/blob/6b217f375119580472c7cd74d5a1d65073d913b6/es-core/src/Sound.cpp#L69

It seems that a user ran into this when he tried the latest development version of SDL2 which requires the SDL audio subsystem to be initialized for SDL_BuildAudioCVT. It's possible that this behavior might change again before SDL 2.0.6 is released, but EmulationStation should make sure it checks for errors properly anyway. And, if the error is about the uninitialized subsystem, it could try to initialize it earlier.

I can't currently provide any patches or testing, but I'll ask if the user is able to provide the latter.

jrassa commented 7 years ago

@ChliHug Thanks for reporting this. I will try to look into this soon.

psyke83 commented 7 years ago

Judging by the latest comments in that bug report, it seems that the function won't require the audio subsystem to be initialized for the function to work as intended. This means that there should be no issue with audio deinit/reinit stuff in my PR#242 when we switch to SDL2 2.0.6.

https://hg.libsdl.org/SDL/rev/41bc8b8e9758

ChliHug commented 7 years ago

Yes, this issue is now just about the missing error check.