msi: Use FIELD_OFFSET for the size of structs with a varlength array.

This commit is contained in:
Michael Stefaniuc 2012-12-13 16:56:42 +01:00 committed by Alexandre Julliard
parent c34769cfa1
commit 62029ff586
3 changed files with 5 additions and 6 deletions

View File

@ -1135,7 +1135,7 @@ static UINT msi_dialog_line_control( msi_dialog *dialog, MSIRECORD *rec )
msi_dialog_map_events(dialog, name);
control = msi_alloc( sizeof(*control) + strlenW(name) * sizeof(WCHAR) );
control = msi_alloc( FIELD_OFFSET(msi_control, name[strlenW( name ) + 1] ));
if (!control)
return ERROR_OUTOFMEMORY;
@ -3735,7 +3735,7 @@ msi_dialog *msi_dialog_create( MSIPACKAGE* package,
msi_dialog_register_class();
/* allocate the structure for the dialog to use */
dialog = msi_alloc_zero( sizeof *dialog + sizeof(WCHAR)*strlenW(szDialogName) );
dialog = msi_alloc_zero( FIELD_OFFSET( msi_dialog, name[strlenW( szDialogName ) + 1] ));
if( !dialog )
return NULL;
strcpyW( dialog->name, szDialogName );

View File

@ -79,15 +79,14 @@ void MSI_CloseRecord( MSIOBJECTHDR *arg )
MSIRECORD *MSI_CreateRecord( UINT cParams )
{
MSIRECORD *rec;
UINT len;
TRACE("%d\n", cParams);
if( cParams>65535 )
return NULL;
len = sizeof (MSIRECORD) + sizeof (MSIFIELD)*cParams;
rec = alloc_msiobject( MSIHANDLETYPE_RECORD, len, MSI_CloseRecord );
rec = alloc_msiobject( MSIHANDLETYPE_RECORD, FIELD_OFFSET(MSIRECORD, fields[cParams + 1]),
MSI_CloseRecord );
if( rec )
rec->count = cParams;
return rec;

View File

@ -1068,7 +1068,7 @@ static UINT WHERE_sort(struct tagMSIVIEW *view, column_info *columns)
if (count == 0)
return ERROR_SUCCESS;
orderinfo = msi_alloc(sizeof(MSIORDERINFO) + (count - 1) * sizeof(union ext_column));
orderinfo = msi_alloc(FIELD_OFFSET(MSIORDERINFO, columns[count]));
if (!orderinfo)
return ERROR_OUTOFMEMORY;