apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Afrasinei <alexandruafrasi...@gmail.com>
Subject apr leak windows
Date Thu, 12 Nov 2009 13:25:36 GMT
Hello,

Used BoundsChecker tool and it reports some leaks/errors on windows in apr.

Function CommandLineToArgvW in apr_app_initialize(misc/win32/start.c).
Some macros are used for this (APR_DECLARE_LATE_DLL_FUNC) and
is called apr_load_dll_func (misc/win32/misc.c) which calls LoadLibrary.
Seems handle for LoadLibrary is never freed with FreeLibrary so a
resource leak is reported when exiting program.

Though the handle is stored in a static array in misc.c (static
HMODULE lateDllHandle[DLL_defined])
To fix this i made a function which calls FreeLibrary on the handle in
lateDllHandle array , and call it in apr_terminate.


Also for same call to CommandLineToArgvW (misc.c)

 wstrs = CommandLineToArgvW(sysstr, &wstrc);
            if (wstrs) {
                *argc = apr_wastrtoastr(argv, wstrs, wstrc);
                GlobalFree(wstrs);
            }

Allocation Conflict: Attempting to call GlobalFree on 0x017BE080;
pointer was allocated by LocalAlloc.


A memory block was allocated with one type of allocator, and
deallocated with an incompatible deallocator.

msdn entry for CommandLineToArgvW says LocalFree should be used.
I dont know if this is a real problem but calling LocalFree instead of
GlobalFree fix the reported error.

Mime
View raw message