1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-29 07:58:30 +02:00

Check if file can't be loaded in SoundTrack::SoundTrack()

This adds a check that the pointer passed to
FILESYSTEM_loadFileToMemory() isn't NULL, and if it is, just returns
early in the function, instead of continuing later and producing a
different, slightly-misleading error message.
This commit is contained in:
Misa 2021-02-15 19:07:32 -08:00 committed by Ethan Lee
parent f401cc6230
commit 8052f61cef

View File

@ -33,6 +33,11 @@ SoundTrack::SoundTrack(const char* fileName)
unsigned char *mem;
size_t length = 0;
FILESYSTEM_loadFileToMemory(fileName, &mem, &length);
if (mem == NULL)
{
fprintf(stderr, "Unable to load WAV file %s\n", fileName);
return;
}
SDL_RWops *fileIn = SDL_RWFromMem(mem, length);
sound = Mix_LoadWAV_RW(fileIn, 1);
FILESYSTEM_freeMemory(&mem);