From 649d2dfb3b7ccfa689eb9fbce2f094fe5c03c738 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Fri, 12 Feb 2016 18:52:20 +0100 Subject: [PATCH] wined3d: Use FIELD_OFFSET to calculate the size in surface_create_dib_section(). Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/surface.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 459cbdcd62..0e6bf282fc 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -379,17 +379,17 @@ HRESULT surface_create_dib_section(struct wined3d_surface *surface) case 2: case 4: /* Allocate extra space to store the RGB bit masks. */ - b_info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BITMAPINFOHEADER) + 3 * sizeof(DWORD)); + b_info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET(BITMAPINFO, bmiColors[3])); break; case 3: - b_info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BITMAPINFOHEADER)); + b_info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET(BITMAPINFO, bmiColors[0])); break; default: /* Allocate extra space for a palette. */ b_info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * (1u << (format->byte_count * 8))); + FIELD_OFFSET(BITMAPINFO, bmiColors[1u << (format->byte_count * 8)])); break; }