[PATCH] dbghelp: Fix use after freed

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Wed Dec 8 14:33:58 CST 2021


module_remove frees the module passed in.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
 dlls/dbghelp/module.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c
index 5614c575cd0..894c713b3ce 100644
--- a/dlls/dbghelp/module.c
+++ b/dlls/dbghelp/module.c
@@ -1058,7 +1058,6 @@ BOOL WINAPI SymUnloadModule64(HANDLE hProcess, DWORD64 BaseOfDll)
     if (!pcs) return FALSE;
     module = module_find_by_addr(pcs, BaseOfDll, DMT_UNKNOWN);
     if (!module) return FALSE;
-    if (!module_remove(pcs, module)) return FALSE;
     /* remove local scope if defined inside this module */
     if (pcs->localscope_pc >= module->module.BaseOfImage &&
         pcs->localscope_pc < module->module.BaseOfImage + module->module.ImageSize)
@@ -1066,6 +1065,7 @@ BOOL WINAPI SymUnloadModule64(HANDLE hProcess, DWORD64 BaseOfDll)
         pcs->localscope_pc = 0;
         pcs->localscope_symt = NULL;
     }
+    if (!module_remove(pcs, module)) return FALSE;
     return TRUE;
 }
 
-- 
2.33.0




More information about the wine-devel mailing list