Commit b89f89323c13a9804d9d521ea9800983f955560a

Pali Rohár 2021-02-03T20:58:15

Move hCurrentProc variable to scope where is used

diff --git a/src/dlfcn.c b/src/dlfcn.c
index 9620692..8cd2fc9 100644
--- a/src/dlfcn.c
+++ b/src/dlfcn.c
@@ -362,14 +362,12 @@ void *dlsym( void *handle, const char *name )
     FARPROC symbol;
     HMODULE hCaller;
     HMODULE hModule;
-    HANDLE hCurrentProc;
 
     error_occurred = FALSE;
 
     symbol = NULL;
     hCaller = NULL;
     hModule = GetModuleHandle( NULL );
-    hCurrentProc = GetCurrentProcess( );
 
     if( handle == RTLD_DEFAULT )
     {
@@ -407,11 +405,14 @@ void *dlsym( void *handle, const char *name )
 
     if( hModule == handle || handle == RTLD_NEXT )
     {
+        HANDLE hCurrentProc;
         HMODULE *modules;
         DWORD cbNeeded;
         DWORD dwSize;
         size_t i;
 
+        hCurrentProc = GetCurrentProcess( );
+
         /* GetModuleHandle( NULL ) only returns the current program file. So
          * if we want to get ALL loaded module including those in linked DLLs,
          * we have to use EnumProcessModules( ).