Skip to content

Commit

Permalink
Add null check to SDL_LoadWAV_RW to avoid crashes
Browse files Browse the repository at this point in the history
Native SDL 1.2 and 2.0 both handle SDL_LoadWAV(null,...), SDL_LoadWAV("",...) and SDL_LoadWAV(nonexistent_file,...)
by returning NULL and setting an error; this check resores that
behavior.

Fixes #310
  • Loading branch information
zmanuel authored and icculus committed Aug 6, 2023
1 parent 9a3e5bc commit 041cf9a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/SDL12_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -8454,6 +8454,10 @@ SDL_LoadWAV_RW(SDL12_RWops *rwops12, int freerwops12,
SDL_RWops *rwops20 = RWops12to20(rwops12);
SDL_AudioSpec *retval = NULL;

if (!rwops20) {
return NULL;
}

*buf = NULL;

/* SDL2's LoadWAV requires a seekable stream, but SDL 1.2 didn't,
Expand Down

0 comments on commit 041cf9a

Please sign in to comment.