From 64acbb55b4411cb44ed00f72d7dcb03805fe55a5 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Tue, 8 Jul 2008 15:18:21 +0100 Subject: [PATCH] user32: sizeof DDEPOKE and DDEDATA is six, which is probably not what is expected, so use offsetof instead. --- dlls/user32/dde_client.c | 2 +- dlls/user32/dde_server.c | 2 +- dlls/user32/message.c | 4 ++-- dlls/user32/tests/dde.c | 7 ++----- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/dlls/user32/dde_client.c b/dlls/user32/dde_client.c index 83bc9fb0ffe..6f7386d68e4 100644 --- a/dlls/user32/dde_client.c +++ b/dlls/user32/dde_client.c @@ -724,7 +724,7 @@ static WDML_XACT* WDML_ClientQueuePoke(WDML_CONV* pConv, LPVOID pData, DWORD cbD GlobalUnlock(hglobal); } - pXAct->hMem = GlobalAlloc(GHND | GMEM_DDESHARE, sizeof(DDEPOKE) + cbData); + pXAct->hMem = GlobalAlloc(GHND | GMEM_DDESHARE, FIELD_OFFSET(DDEPOKE, Value[cbData])); ddePoke = GlobalLock(pXAct->hMem); if (!ddePoke) { diff --git a/dlls/user32/dde_server.c b/dlls/user32/dde_server.c index a2064a01594..1c75bff5907 100644 --- a/dlls/user32/dde_server.c +++ b/dlls/user32/dde_server.c @@ -844,7 +844,7 @@ static WDML_QUEUE_STATE WDML_ServerHandlePoke(WDML_CONV* pConv, WDML_XACT* pXAct if (!(pConv->instance->CBFflags & CBF_FAIL_POKES)) { hDdeData = DdeCreateDataHandle(pConv->instance->instanceID, pDdePoke->Value, - GlobalSize(pXAct->hMem) - sizeof(DDEPOKE) + 1, + GlobalSize(pXAct->hMem) - FIELD_OFFSET(DDEPOKE, Value), 0, 0, pDdePoke->cfFormat, 0); if (hDdeData) { diff --git a/dlls/user32/message.c b/dlls/user32/message.c index 6588f8e7e8f..522ff386db4 100644 --- a/dlls/user32/message.c +++ b/dlls/user32/message.c @@ -1456,8 +1456,8 @@ static BOOL post_dde_message( struct packed_message *data, const struct send_mes { size = GlobalSize( (HGLOBAL)uiLo ) ; if ((info->msg == WM_DDE_ADVISE && size < sizeof(DDEADVISE)) || - (info->msg == WM_DDE_DATA && size < sizeof(DDEDATA)) || - (info->msg == WM_DDE_POKE && size < sizeof(DDEPOKE)) + (info->msg == WM_DDE_DATA && size < FIELD_OFFSET(DDEDATA, Value)) || + (info->msg == WM_DDE_POKE && size < FIELD_OFFSET(DDEPOKE, Value)) ) return FALSE; } diff --git a/dlls/user32/tests/dde.c b/dlls/user32/tests/dde.c index f082314b2b1..56c8893ed2a 100644 --- a/dlls/user32/tests/dde.c +++ b/dlls/user32/tests/dde.c @@ -699,10 +699,7 @@ static HDDEDATA CALLBACK server_ddeml_callback(UINT uType, UINT uFmt, HCONV hcon ptr = (LPSTR)DdeAccessData(hdata, &size); ok(!lstrcmpA(ptr, "poke data\r\n"), "Expected 'poke data\\r\\n', got %s\n", ptr); - todo_wine - { - ok(size == 14, "Expected 14, got %d\n", size); - } + ok(size == 12, "Expected 12, got %d\n", size); DdeUnaccessData(hdata); size = DdeQueryStringA(server_pid, hsz2, str, MAX_PATH, CP_WINANSI); @@ -981,7 +978,7 @@ static HGLOBAL create_poke() DDEPOKE *poke; DWORD size; - size = sizeof(DDEPOKE) + lstrlenA("poke data\r\n") + 1; + size = FIELD_OFFSET(DDEPOKE, Value[sizeof("poke data\r\n")]); hglobal = GlobalAlloc(GMEM_DDESHARE, size); ok(hglobal != 0, "Expected non-NULL hglobal\n");