From fbcbdd8fa270237b2aab8cff549cff7e10b5149d Mon Sep 17 00:00:00 2001 From: DokiDokiPB <20497934+a1091150@users.noreply.github.com> Date: Sun, 28 Jul 2024 22:45:39 +0800 Subject: [PATCH] Fix segmentation fault after destorying window Function _twin_sdl_destroy destroys the screen before the backend destroyed. This causes a segmentation fault or an endless loop. This commit changes the sequence of destruction in the function. --- backend/sdl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/sdl.c b/backend/sdl.c index 5198c2c..1501679 100644 --- a/backend/sdl.c +++ b/backend/sdl.c @@ -58,12 +58,12 @@ static void _twin_sdl_put_span(twin_coord_t left, static void _twin_sdl_destroy(twin_screen_t *screen, twin_sdl_t *tx) { - twin_screen_destroy(screen); - SDL_DestroyTexture(tx->texture); SDL_DestroyRenderer(tx->render); SDL_DestroyWindow(tx->win); SDL_Quit(); + + twin_screen_destroy(screen); } static void twin_sdl_damage(twin_screen_t *screen, twin_sdl_t *tx)