From 53446c190beaf75a49669d196a9c8a3dadd8a39b Mon Sep 17 00:00:00 2001 From: Franck STAUFFER Date: Tue, 4 Aug 2020 09:02:24 +0200 Subject: [PATCH] Clean previously created data when exiting in init_SDL() --- src/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main.c b/src/main.c index a70608f..19d5504 100644 --- a/src/main.c +++ b/src/main.c @@ -110,17 +110,23 @@ init_SDL(const char* path) if (!w) { fputs("ERROR: Failed to create a window\n", stderr); + SDL_Quit(); return 0; } s = SDL_GetWindowSurface(w); if (!s) { fputs("ERROR: Failed to get window's surface\n", stderr); + SDL_DestroyWindow(w); + SDL_Quit(); return 0; } if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 1, 1024)) { fputs("ERROR: Failed to open audio\n", stderr); + SDL_FreeSurface(s); + SDL_DestroyWindow(w); + SDL_Quit(); return 0; } @@ -130,6 +136,10 @@ init_SDL(const char* path) buzzer = Mix_LoadWAV("resources/buzzer.wav"); if (!buzzer) { fputs("ERROR: Failed to load sound effects\n", stderr); + Mix_Quit(); + SDL_FreeSurface(s); + SDL_DestroyWindow(w); + SDL_Quit(); return 0; }