Thomas Faber : dplayx: Fix broken pointer arithmetic.
Alexandre Julliard
julliard at winehq.org
Tue Mar 25 14:27:43 CDT 2014
Module: wine
Branch: master
Commit: 4b1fb32d9dba1eee5e4ac09bd5a97541a32ff652
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4b1fb32d9dba1eee5e4ac09bd5a97541a32ff652
Author: Thomas Faber <thomas.faber at reactos.org>
Date: Tue Mar 25 11:11:25 2014 +0100
dplayx: Fix broken pointer arithmetic.
---
dlls/dplayx/dplayx_global.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/dlls/dplayx/dplayx_global.c b/dlls/dplayx/dplayx_global.c
index 55a7386..f68cad0 100644
--- a/dlls/dplayx/dplayx_global.c
+++ b/dlls/dplayx/dplayx_global.c
@@ -84,8 +84,9 @@ static LPVOID lpSharedStaticData = NULL;
typedef struct
{
BOOL used;
- DWORD data[dwBlockSize-sizeof(DWORD)];
+ BYTE data[dwBlockSize - sizeof(BOOL)];
} DPLAYX_MEM_SLICE;
+C_ASSERT(sizeof(DPLAYX_MEM_SLICE) == dwBlockSize);
static DPLAYX_MEM_SLICE* lpMemArea;
@@ -100,7 +101,7 @@ static void DPLAYX_PrivHeapFree( LPVOID addr )
return;
}
- lpAddrStart = (char*)addr - sizeof(DWORD); /* Find block header */
+ lpAddrStart = CONTAINING_RECORD(addr, DPLAYX_MEM_SLICE, data); /* Find block header */
dwBlockUsed = ((BYTE*)lpAddrStart - (BYTE*)lpMemArea)/dwBlockSize;
lpMemArea[ dwBlockUsed ].used = FALSE;
@@ -111,10 +112,10 @@ static LPVOID DPLAYX_PrivHeapAlloc( DWORD flags, DWORD size )
LPVOID lpvArea = NULL;
UINT uBlockUsed;
- if( size > (dwBlockSize - sizeof(DWORD)) )
+ if( size > (dwBlockSize - sizeof(BOOL)) )
{
FIXME( "Size exceeded. Request of 0x%08x\n", size );
- size = dwBlockSize - sizeof(DWORD);
+ size = dwBlockSize - sizeof(BOOL);
}
/* Find blank area */
More information about the wine-cvs
mailing list