msi: Use FIELD_OFFSET to calculate the size of structs with variable length array.
This commit is contained in:
parent
9c431b6737
commit
51013ad278
|
@ -309,7 +309,7 @@ static UINT msi_dialog_add_font( MSIRECORD *rec, LPVOID param )
|
||||||
|
|
||||||
/* create a font and add it to the list */
|
/* create a font and add it to the list */
|
||||||
name = MSI_RecordGetString( rec, 1 );
|
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 );
|
strcpyW( font->name, name );
|
||||||
list_add_head( &dialog->fonts, &font->entry );
|
list_add_head( &dialog->fonts, &font->entry );
|
||||||
|
|
||||||
|
@ -414,7 +414,7 @@ static msi_control *msi_dialog_create_window( msi_dialog *dialog,
|
||||||
|
|
||||||
style |= WS_CHILD;
|
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)
|
if (!control)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
@ -2141,7 +2141,7 @@ UINT TABLE_CreateView( MSIDATABASE *db, LPCWSTR name, MSIVIEW **view )
|
||||||
else if ( !strcmpW( name, szStorages ) )
|
else if ( !strcmpW( name, szStorages ) )
|
||||||
return STORAGES_CreateView( db, view );
|
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 );
|
tv = msi_alloc_zero( sz );
|
||||||
if( !tv )
|
if( !tv )
|
||||||
return ERROR_FUNCTION_FAILED;
|
return ERROR_FUNCTION_FAILED;
|
||||||
|
|
Loading…
Reference in New Issue