Skip to content

Commit a328f78

Browse files
authored
Merge pull request #137 from sysprog21/fix-sdl-cleanup
Prevent resource leak in SDL backend
2 parents 62aaf7e + 6f9aebe commit a328f78

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

backend/sdl.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ twin_context_t *twin_sdl_init(int width, int height)
137137
SDL_WINDOW_SHOWN);
138138
if (!tx->win) {
139139
log_error("%s", SDL_GetError());
140-
goto bail;
140+
goto bail_sdl;
141141
}
142142

143143
tx->pixels = malloc(width * height * sizeof(*tx->pixels));
@@ -192,6 +192,8 @@ twin_context_t *twin_sdl_init(int width, int height)
192192
free(tx->pixels);
193193
bail_window:
194194
SDL_DestroyWindow(tx->win);
195+
bail_sdl:
196+
SDL_Quit();
195197
bail:
196198
free(ctx->priv);
197199
free(ctx);

0 commit comments

Comments
 (0)