https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7ed0f25b64932f079dfdf…
commit 7ed0f25b64932f079dfdfd68e9ad1675fa606114
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Fri Oct 9 14:28:32 2020 +0200
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Oct 11 16:30:39 2020 +0200
[GDI32] Prevent double initialization in GdiProcessSetup
Found with Application Verifier :)
---
win32ss/gdi/gdi32/main/dllmain.c | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/win32ss/gdi/gdi32/main/dllmain.c b/win32ss/gdi/gdi32/main/dllmain.c
index b59dfbe4210..322fc156435 100644
--- a/win32ss/gdi/gdi32/main/dllmain.c
+++ b/win32ss/gdi/gdi32/main/dllmain.c
@@ -4,6 +4,7 @@
#include <precomp.h>
+static BOOL gbInitialized = FALSE;
extern HGDIOBJ stock_objects[];
BOOL SetStockObjects = FALSE;
PDEVCAPS GdiDevCaps = NULL;
@@ -40,18 +41,22 @@ VOID
WINAPI
GdiProcessSetup(VOID)
{
- hProcessHeap = GetProcessHeap();
-
- /* map the gdi handle table to user space */
- GdiHandleTable =
NtCurrentTeb()->ProcessEnvironmentBlock->GdiSharedHandleTable;
- GdiSharedHandleTable =
NtCurrentTeb()->ProcessEnvironmentBlock->GdiSharedHandleTable;
- GdiDevCaps = &GdiSharedHandleTable->DevCaps;
- CurrentProcessId = NtCurrentTeb()->ClientId.UniqueProcess;
- GDI_BatchLimit = (DWORD)
NtCurrentTeb()->ProcessEnvironmentBlock->GdiDCAttributeList;
- GdiHandleCache =
(PGDIHANDLECACHE)NtCurrentTeb()->ProcessEnvironmentBlock->GdiHandleBuffer;
- RtlInitializeCriticalSection(&semLocal);
- InitializeCriticalSection(&gcsClientObjLinks);
- GdiInitializeLanguagePack(0);
+ if (!gbInitialized)
+ {
+ gbInitialized = TRUE;
+ hProcessHeap = GetProcessHeap();
+
+ /* map the gdi handle table to user space */
+ GdiHandleTable =
NtCurrentTeb()->ProcessEnvironmentBlock->GdiSharedHandleTable;
+ GdiSharedHandleTable =
NtCurrentTeb()->ProcessEnvironmentBlock->GdiSharedHandleTable;
+ GdiDevCaps = &GdiSharedHandleTable->DevCaps;
+ CurrentProcessId = NtCurrentTeb()->ClientId.UniqueProcess;
+ GDI_BatchLimit = (DWORD)
NtCurrentTeb()->ProcessEnvironmentBlock->GdiDCAttributeList;
+ GdiHandleCache =
(PGDIHANDLECACHE)NtCurrentTeb()->ProcessEnvironmentBlock->GdiHandleBuffer;
+ RtlInitializeCriticalSection(&semLocal);
+ InitializeCriticalSection(&gcsClientObjLinks);
+ GdiInitializeLanguagePack(0);
+ }
}
VOID