Commit 9016d1ed authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

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

parent 89d40b3d
......@@ -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]);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment