libsdl-org/sdl12-compat

SDL_LoadWAV() crashes with invalid files

zmanuel opened this issue · 0 comments

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.