user32/tests: Use FIELD_OFFSET to calculate the size of a struct with variable length array

Michael Stefaniuc mstefani at redhat.de
Mon Oct 29 05:50:30 CDT 2012


---
 dlls/user32/tests/dde.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/dlls/user32/tests/dde.c b/dlls/user32/tests/dde.c
index 3ad48f0..3a1c7c0 100644
--- a/dlls/user32/tests/dde.c
+++ b/dlls/user32/tests/dde.c
@@ -143,7 +143,8 @@ static LRESULT WINAPI dde_server_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPA
         else
             lstrcpyA(str, "requested data\r\n");
 
-        size = sizeof(DDEDATA) + lstrlenA(str) + 1;
+        /* Extra space to escape "\r\n" and terminating 0 */
+        size = FIELD_OFFSET(DDEDATA, Value[lstrlenA(str) + 3]);
         hglobal = GlobalAlloc(GMEM_MOVEABLE, size);
         ok(hglobal != NULL, "Expected non-NULL hglobal\n");
 
-- 
1.7.7.6



More information about the wine-patches mailing list