[Bug 20711] Flatout2 demo crashes on exit

wine-bugs at winehq.org wine-bugs at winehq.org
Tue Mar 30 09:22:40 CDT 2010


http://bugs.winehq.org/show_bug.cgi?id=20711





--- Comment #25 from Markus <mst at collogia.de>  2010-03-30 09:22:40 ---
> Doesn't that still try to call FreeLibrary() from apartment_release() ->
> COMPOBJ_DllList_ReleaseRef() though?
> 

GetModuleHandleExW(0, ... increases the reference counter and ensures that the
library is still loaded. So we can survive another call to FreeLibrary until
DllCanUnloadNow is called. In this case we have to call FreeLibrary twice. One
can be done in the original position.

Thanks to your comment I have seen another issue. COMPOBJ_DllList_ReleaseRef()
releases the memory of entry. so I need a separate variable for that.
Correction should be as follows:

static void apartment_freeunusedlibraries(struct apartment *apt, DWORD delay)
{
    struct apartment_loaded_dll *entry, *next;
*   HANDLE hLibrary;
*   BOOL res; 

    ...

*   res = GetModuleHandleExW(0, entry->dll->library_name, &hLibrary);
*   if (   res 
        && entry->dll->DllCanUnloadNow 
        && (entry->dll->DllCanUnloadNow() == S_OK))
    {

    ...

    }
    else if (entry->unload_time)
            entry->unload_time = 0;

*   if (res) FreeLibrary(hLibrary);

-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
Do not reply to this email, post in Bugzilla using the
above URL to reply.
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the wine-bugs mailing list