Free data upon failure in LoadImage()

Otherwise, if SDL_CreateRGBSurfaceFrom() returned NULL, then this memory
would be leaked.
This commit is contained in:
Misa 2021-01-13 22:56:19 -08:00 committed by Ethan Lee
parent 626aac59fb
commit adbab6355b
1 changed files with 1 additions and 0 deletions

View File

@ -76,6 +76,7 @@ static SDL_Surface* LoadImage(const char *filename, bool noBlend = true, bool no
}
else
{
SDL_free(data);
fprintf(stderr,"Image not found: %s\n", filename);
SDL_assert(0 && "Image not found! See stderr.");
return NULL;