Zhiyi Zhang : uxtheme: Avoid memory leaks.

Alexandre Julliard julliard at winehq.org
Mon Jul 5 16:24:20 CDT 2021


Module: wine
Branch: master
Commit: 6f00a2983aa54bf540ecff79d9fddd5059f2da41
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=6f00a2983aa54bf540ecff79d9fddd5059f2da41

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Mon Jul  5 20:33:49 2021 +0800

uxtheme: Avoid memory leaks.

A THEME_FILE struct and four global ATOMs are leaked when unloading uxtheme.

Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/uxtheme/main.c       |  8 ++++++--
 dlls/uxtheme/system.c     | 10 ++++++++++
 dlls/uxtheme/uxthemedll.h |  1 +
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/dlls/uxtheme/main.c b/dlls/uxtheme/main.c
index 5e5610a1f84..5f79dd6ed0d 100644
--- a/dlls/uxtheme/main.c
+++ b/dlls/uxtheme/main.c
@@ -31,14 +31,18 @@ WINE_DEFAULT_DEBUG_CHANNEL(uxtheme);
 /***********************************************************************/
 
 /* For the moment, do nothing here. */
-BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
+BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, void *reserved)
 {
-    TRACE("%p 0x%x %p\n", hInstDLL, fdwReason, lpv);
+    TRACE("%p 0x%x %p\n", hInstDLL, fdwReason, reserved);
     switch(fdwReason) {
         case DLL_PROCESS_ATTACH:
             DisableThreadLibraryCalls(hInstDLL);
             UXTHEME_InitSystem(hInstDLL);
             break;
+        case DLL_PROCESS_DETACH:
+            if (reserved) break;
+            UXTHEME_UninitSystem();
+            break;
     }
     return TRUE;
 }
diff --git a/dlls/uxtheme/system.c b/dlls/uxtheme/system.c
index b18794740a8..dcd2a660042 100644
--- a/dlls/uxtheme/system.c
+++ b/dlls/uxtheme/system.c
@@ -509,6 +509,16 @@ void UXTHEME_InitSystem(HINSTANCE hInst)
     UXTHEME_LoadTheme();
 }
 
+void UXTHEME_UninitSystem(void)
+{
+    MSSTYLES_SetActiveTheme(NULL, FALSE);
+
+    GlobalDeleteAtom(atWindowTheme);
+    GlobalDeleteAtom(atSubAppName);
+    GlobalDeleteAtom(atSubIdList);
+    GlobalDeleteAtom(atDialogThemeEnabled);
+}
+
 /***********************************************************************
  *      IsAppThemed                                         (UXTHEME.@)
  */
diff --git a/dlls/uxtheme/uxthemedll.h b/dlls/uxtheme/uxthemedll.h
index fee152c9c34..fdf529b422a 100644
--- a/dlls/uxtheme/uxthemedll.h
+++ b/dlls/uxtheme/uxthemedll.h
@@ -95,6 +95,7 @@ HRESULT WINAPI ParseThemeIniFile(LPCWSTR pszIniFileName, LPWSTR pszUnknown,
                                  ParseThemeIniFileProc callback, LPVOID lpData) DECLSPEC_HIDDEN;
 
 extern void UXTHEME_InitSystem(HINSTANCE hInst) DECLSPEC_HIDDEN;
+extern void UXTHEME_UninitSystem(void) DECLSPEC_HIDDEN;
 
 /* No alpha blending */
 #define ALPHABLEND_NONE             0




More information about the wine-cvs mailing list