Michael Stefaniuc : msi: Use FIELD_OFFSET to calculate the size of structs with variable length array .
Alexandre Julliard
julliard at winehq.org
Fri Nov 9 11:03:23 CST 2012
Module: wine
Branch: master
Commit: 51013ad27844de2a176287b6f3edbeccd972ee68
URL: http://source.winehq.org/git/wine.git/?a=commit;h=51013ad27844de2a176287b6f3edbeccd972ee68
Author: Michael Stefaniuc <mstefani at redhat.de>
Date: Fri Nov 9 16:47:44 2012 +0100
msi: Use FIELD_OFFSET to calculate the size of structs with variable length array.
---
dlls/msi/dialog.c | 4 ++--
dlls/msi/table.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/msi/dialog.c b/dlls/msi/dialog.c
index 85d5859..c0ff204 100644
--- a/dlls/msi/dialog.c
+++ b/dlls/msi/dialog.c
@@ -309,7 +309,7 @@ static UINT msi_dialog_add_font( MSIRECORD *rec, LPVOID param )
/* create a font and add it to the list */
name = MSI_RecordGetString( rec, 1 );
- font = msi_alloc( sizeof *font + strlenW( name )*sizeof (WCHAR) );
+ font = msi_alloc( FIELD_OFFSET( msi_font, name[strlenW( name ) + 1] ));
strcpyW( font->name, name );
list_add_head( &dialog->fonts, &font->entry );
@@ -414,7 +414,7 @@ static msi_control *msi_dialog_create_window( msi_dialog *dialog,
style |= WS_CHILD;
- control = msi_alloc( sizeof *control + strlenW(name)*sizeof(WCHAR) );
+ control = msi_alloc( FIELD_OFFSET( msi_control, name[strlenW( name ) + 1] ));
if (!control)
return NULL;
diff --git a/dlls/msi/table.c b/dlls/msi/table.c
index c5aa685..e2186fc 100644
--- a/dlls/msi/table.c
+++ b/dlls/msi/table.c
@@ -2141,7 +2141,7 @@ UINT TABLE_CreateView( MSIDATABASE *db, LPCWSTR name, MSIVIEW **view )
else if ( !strcmpW( name, szStorages ) )
return STORAGES_CreateView( db, view );
- sz = sizeof *tv + lstrlenW(name)*sizeof name[0] ;
+ sz = FIELD_OFFSET( MSITABLEVIEW, name[lstrlenW( name ) + 1] );
tv = msi_alloc_zero( sz );
if( !tv )
return ERROR_FUNCTION_FAILED;
More information about the wine-cvs
mailing list