[PATCH] dlls/win32u: ensure enum is large enough to store a LONG

Eric Pouech eric.pouech at gmail.com
Fri May 20 10:17:24 CDT 2022


nothing ensures that the enum's storage has the size of an int
C standard says:
- at least size of a char
- large enough to store all values of enum without cropping them
- (signed vs unsigned is compiler dependant as well)

even if it's unlikely it would be defined with something else than an int, added a C_ASSERT just in case

Signed-off-by: Eric Pouech <eric.pouech at gmail.com>

---
 dlls/win32u/sysparams.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c
index dd494188121..13f9e6c0025 100644
--- a/dlls/win32u/sysparams.c
+++ b/dlls/win32u/sysparams.c
@@ -4575,6 +4575,7 @@ BOOL WINAPI NtUserSetSysColors( INT count, const INT *colors, const COLORREF *va
 
 
 static DPI_AWARENESS dpi_awareness;
+C_ASSERT(sizeof(dpi_awareness) == sizeof(LONG));
 
 /***********************************************************************
  *	     NtUserSetProcessDpiAwarenessContext    (win32u.@)
@@ -4594,7 +4595,7 @@ BOOL WINAPI NtUserSetProcessDpiAwarenessContext( ULONG awareness, ULONG unknown
         return FALSE;
     }
 
-    return !InterlockedCompareExchange( &dpi_awareness, awareness, 0 );
+    return !InterlockedCompareExchange( (LONG*)&dpi_awareness, awareness, 0 );
 }
 
 /***********************************************************************




More information about the wine-devel mailing list