Michael Stefaniuc : gdi.exe16: Use FIELD_OFFSET to calculate the size of structs with variable length array .

Alexandre Julliard julliard at winehq.org
Fri Nov 2 15:52:03 CDT 2012


Module: wine
Branch: master
Commit: fb724cfd7be65905eadcb832794f83a9bb1ff383
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=fb724cfd7be65905eadcb832794f83a9bb1ff383

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Fri Nov  2 15:13:55 2012 +0100

gdi.exe16: Use FIELD_OFFSET to calculate the size of structs with variable length array.

---

 dlls/gdi.exe16/gdi.c      |    2 +-
 dlls/gdi.exe16/metafile.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlls/gdi.exe16/gdi.c b/dlls/gdi.exe16/gdi.c
index ef460b3..2bd070b 100644
--- a/dlls/gdi.exe16/gdi.c
+++ b/dlls/gdi.exe16/gdi.c
@@ -1982,7 +1982,7 @@ void WINAPI SetRectRgn16( HRGN16 hrgn, INT16 left, INT16 top, INT16 right, INT16
  */
 void WINAPI PlayMetaFileRecord16( HDC16 hdc, HANDLETABLE16 *ht, METARECORD *mr, UINT16 handles )
 {
-    HANDLETABLE *ht32 = HeapAlloc( GetProcessHeap(), 0, handles * sizeof(*ht32) );
+    HANDLETABLE *ht32 = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET(HANDLETABLE, objectHandle[handles] ));
     unsigned int i;
 
     for (i = 0; i < handles; i++) ht32->objectHandle[i] = HGDIOBJ_32(ht->objectHandle[i]);
diff --git a/dlls/gdi.exe16/metafile.c b/dlls/gdi.exe16/metafile.c
index dfde8f7..2f0ccfe 100644
--- a/dlls/gdi.exe16/metafile.c
+++ b/dlls/gdi.exe16/metafile.c
@@ -213,7 +213,7 @@ BOOL16 WINAPI EnumMetaFile16( HDC16 hdc16, HMETAFILE16 hmf,
     /* create the handle table */
 
     hHT = GlobalAlloc16(GMEM_MOVEABLE | GMEM_ZEROINIT,
-		     sizeof(HANDLETABLE16) * mh->mtNoObjects);
+            FIELD_OFFSET(HANDLETABLE16, objectHandle[mh->mtNoObjects]));
     spht = WOWGlobalLock16(hHT);
 
     seg = hmf | 7;




More information about the wine-cvs mailing list