libsdl-org / sdl12-compat

An SDL-1.2 compatibility layer that uses SDL 2.0 behind the scenes.
Other
191 stars 40 forks source link

SDL_LoadWAV() crashes with invalid files #310

Closed zmanuel closed 11 months ago

zmanuel commented 11 months ago

With native SDL 1.2, that used to return NULL and set an appropriate error.

To reproduce, simply call the loopwave test with a nonsense argument.

The fix is a simple standard early NULL check with return in SDL_LoadWAV_RW, I'll submit a PR momentarily.

We found this because our silly old game uses SDL_LoadWAV to just speculatively load optional sound files, and that crashes now: https://forums3.armagetronad.net/viewtopic.php?t=39657 A workaround is already in the release pipeline, so no hurry.

Looking around: The similar SDL_LoadBMP(_RW) handles NULL arguments fine already. I have not looked too deeply into SDL_SaveBMP. Calling it with both arguments NULL crashes, too, but because of the NULL surface argument; in native SDL1.2, a NULL surface and a valid file would already crash.