itss: Use FIELD_OFFSET to calculate the size of a struct with variable length array

Michael Stefaniuc mstefani at redhat.de
Fri Nov 2 09:17:06 CDT 2012


---
 dlls/itss/moniker.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/dlls/itss/moniker.c b/dlls/itss/moniker.c
index dedf4e5..0509c9e 100644
--- a/dlls/itss/moniker.c
+++ b/dlls/itss/moniker.c
@@ -354,7 +354,7 @@ static HRESULT ITS_IMoniker_create( IMoniker **ppObj, LPCWSTR name, DWORD n )
     DWORD sz;
 
     /* szFile[1] has space for one character already */
-    sz = sizeof(ITS_IMonikerImpl) + strlenW( name )*sizeof(WCHAR);
+    sz = FIELD_OFFSET( ITS_IMonikerImpl, szFile[strlenW( name ) + 1] );
 
     itsmon = HeapAlloc( GetProcessHeap(), 0, sz );
     itsmon->IMoniker_iface.lpVtbl = &ITS_IMonikerImpl_Vtbl;
-- 
1.7.7.6



More information about the wine-patches mailing list