Huw Davies : user32: sizeof DDEPOKE and DDEDATA is six, which is probably not what is expected, so use offsetof instead.
Alexandre Julliard
julliard at winehq.org
Tue Jul 8 14:35:16 CDT 2008
Module: wine
Branch: master
Commit: 64acbb55b4411cb44ed00f72d7dcb03805fe55a5
URL: http://source.winehq.org/git/wine.git/?a=commit;h=64acbb55b4411cb44ed00f72d7dcb03805fe55a5
Author: Huw Davies <huw at codeweavers.com>
Date: Tue Jul 8 15:18:21 2008 +0100
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 83bc9fb..6f7386d 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 a2064a0..1c75bff 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 6588f8e..522ff38 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 f082314..56c8893 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");
More information about the wine-cvs
mailing list