Henri Verbeet : gdi32: Use FIELD_OFFSET to calculate the structure size in GetRegionData().

Alexandre Julliard julliard at winehq.org
Tue May 6 13:37:12 CDT 2014


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Tue May  6 13:06:22 2014 +0200

gdi32: Use FIELD_OFFSET to calculate the structure size in GetRegionData().

---

 dlls/gdi32/region.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/dlls/gdi32/region.c b/dlls/gdi32/region.c
index 2632de5..93aa6a7 100644
--- a/dlls/gdi32/region.c
+++ b/dlls/gdi32/region.c
@@ -886,13 +886,13 @@ DWORD WINAPI GetRegionData(HRGN hrgn, DWORD count, LPRGNDATA rgndata)
     if(!obj) return 0;
 
     size = obj->numRects * sizeof(RECT);
-    if(count < (size + sizeof(RGNDATAHEADER)) || rgndata == NULL)
+    if (!rgndata || count < FIELD_OFFSET(RGNDATA, Buffer[size]))
     {
         GDI_ReleaseObj( hrgn );
 	if (rgndata) /* buffer is too small, signal it by return 0 */
 	    return 0;
-	else		/* user requested buffer size with rgndata NULL */
-	    return size + sizeof(RGNDATAHEADER);
+        /* user requested buffer size with rgndata NULL */
+        return FIELD_OFFSET(RGNDATA, Buffer[size]);
     }
 
     rgndata->rdh.dwSize = sizeof(RGNDATAHEADER);
@@ -907,7 +907,7 @@ DWORD WINAPI GetRegionData(HRGN hrgn, DWORD count, LPRGNDATA rgndata)
     memcpy( rgndata->Buffer, obj->rects, size );
 
     GDI_ReleaseObj( hrgn );
-    return size + sizeof(RGNDATAHEADER);
+    return FIELD_OFFSET(RGNDATA, Buffer[size]);
 }
 
 




More information about the wine-cvs mailing list