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; }