+2021-08-08 Bruno Haible <bruno@clisp.org>
+
+ relocatable-lib-lgpl: Fix a memory leak related to a Windows DLL.
+ Reported by Jonathan Boeing <jonathan@claws-mail.org> in
+ <https://lists.gnu.org/archive/html/bug-gnulib/2021-08/msg00048.html>.
+ * lib/relocatable.c (DllMain): Avoid memory leak in a special case
+ of repeated attach/detach.
+
2021-08-08 Bruno Haible <bruno@clisp.org>
fopen: Fix link error on native Windows.
supports longer file names
(see <https://cygwin.com/ml/cygwin/2011-01/msg00410.html>). */
-/* Determine the full pathname of the shared library when it is loaded. */
+/* Determine the full pathname of the shared library when it is loaded.
+
+ Documentation:
+ <https://docs.microsoft.com/en-us/windows/win32/dlls/dllmain> */
BOOL WINAPI
DllMain (HINSTANCE module_handle, DWORD event, LPVOID reserved)
/* Shouldn't happen. */
return FALSE;
- shared_library_fullname = strdup (location);
+ /* Avoid a memory leak when the same DLL get attached, detached,
+ attached, detached, and so on. This happens e.g. when a spell
+ checker DLL is used repeatedly by a mail program. */
+ if (!(shared_library_fullname != NULL
+ && strcmp (shared_library_fullname, location) == 0))
+ /* Remember the full pathname of the shared library. */
+ shared_library_fullname = strdup (location);
}
return TRUE;