user.exe16: Use FIELD_OFFSET to calculate the size of a struct with variable length array

Michael Stefaniuc mstefani at redhat.de
Mon Nov 12 03:39:45 CST 2012


---
 dlls/user.exe16/user.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/dlls/user.exe16/user.c b/dlls/user.exe16/user.c
index 7f184a2..dddf535 100644
--- a/dlls/user.exe16/user.c
+++ b/dlls/user.exe16/user.c
@@ -1320,7 +1320,8 @@ BOOL16 WINAPI GrayString16( HDC16 hdc, HBRUSH16 hbr, GRAYSTRINGPROC16 gsprc,
         struct gray_string_info *info;
 
         if (!cch) cch = strlen(str16);
-        if (!(info = HeapAlloc( GetProcessHeap(), 0, sizeof(*info) + cch ))) return FALSE;
+        info = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( struct gray_string_info, str[cch + 1] ));
+        if (!info) return FALSE;
         info->proc  = gsprc;
         info->param = lParam;
         memcpy( info->str, str16, cch );
-- 
1.7.7.6



More information about the wine-patches mailing list