[SDL] Possible handle leak

Ulrich Eckhardt doomster at knuut.de
Mon Oct 29 23:17:53 PDT 2007


On Sunday 28 October 2007 20:47:37 liam mail wrote:
> file: \video\wincommon\sdl_syswm.c
[...]
>     static int tried_loading = 0;
>     static PtrSetWindowTextW swtw = NULL;
>     Uint16 *lpsz = SDL_iconv_utf8_ucs2(title);
>     if (!tried_loading) {
>         HMODULE dll = LoadLibrary("user32.dll");
>         if (dll != NULL) {
>             swtw = (PtrSetWindowTextW) GetProcAddress(dll,
>                     "SetWindowTextW");
>             if (swtw == NULL) {
>                 FreeLibrary(dll);
>             }
>         }
>         tried_loading = 1;
>     }
[...]
> The call to load the library "HMODULE dll = LoadLibrary("user32.dll")"

This DLL is not unloaded except by terminating the program and I would say 
it's by design. It wouldn't be unloaded anyway, only its refcounter 
decremented, because user32.dll is loaded in pretty much any process. 
Further, it is also only loaded once, notice the 'static' for 'tried_loading' 
and 'swtw'.

Summary: it could be technically called a leak, but it doesn't create a 
resource problem.

Uli


More information about the SDL mailing list