We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3290

Summary: showimage leaks renderer and doesn't call SDL_VideoQuit
Product: SDL_image Reporter: Juha Niemimäki <juha.niemimaki>
Component: miscAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sylvain.becker
Version: 2.0.1   
Hardware: All   
OS: All   

Description Juha Niemimäki 2016-03-15 18:11:45 UTC
I was testing SDL_image2 on AmigaOS 4 platform. Noticed a couple of issues with 'showimage' tool:

1) SDL_VideoInit seems to be called implicitly via window creation. SDL_Quit doesn't call SDL_VideoQuit so it doesn't close video device, windows etc. properly. Proposal: add SDL_Init(SDL_INIT_VIDEO) in the beginning for symmetrical video init/deinit.

2) Renderer is not destroyed at the end. As far as I know SDL2 doesn't automatically delete renderers. Proposal: add SDL_DestroyRenderer(renderer) at the end.
Comment 1 Sylvain 2017-09-11 19:48:22 UTC
Small patch for this:

--- a/showimage.c	Sat Sep 09 18:57:05 2017 -0700
+++ b/showimage.c	Mon Sep 11 21:47:56 2017 +0200
@@ -76,6 +76,11 @@
         }
     }
 
+    if (SDL_Init(SDL_INIT_VIDEO) == -1) {
+        fprintf(stderr, "SDL_Init(SDL_INIT_VIDEO) failed: %s\n", SDL_GetError());
+        return(2);
+    }
+
     if (SDL_CreateWindowAndRenderer(0, 0, flags, &window, &renderer) < 0) {
         fprintf(stderr, "SDL_CreateWindowAndRenderer() failed: %s\n", SDL_GetError());
         return(2);
@@ -169,6 +174,10 @@
         SDL_DestroyTexture(texture);
     }
 
+
+    SDL_DestroyRenderer(renderer);
+    SDL_DestroyWindow(window);
+
     /* We're done! */
     SDL_Quit();
     return(0);
Comment 2 Sam Lantinga 2017-09-12 04:23:18 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL_image/rev/28967769bc2e