diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index 10921e9231e..f000d7cf022 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -272,7 +272,6 @@ extern MSIHANDLE msiobj_findhandle( MSIOBJECTHDR *hdr ); /* add this table to the list of cached tables in the database */ extern void add_table(MSIDATABASE *db, MSITABLE *table); extern void remove_table( MSIDATABASE *db, MSITABLE *table ); -extern void free_table( MSIDATABASE *db, MSITABLE *table ); extern void free_cached_tables( MSIDATABASE *db ); extern UINT find_cached_table(MSIDATABASE *db, LPCWSTR name, MSITABLE **table); extern UINT get_table(MSIDATABASE *db, LPCWSTR name, MSITABLE **table); diff --git a/dlls/msi/table.c b/dlls/msi/table.c index 6915505545e..67dea44d3f9 100644 --- a/dlls/msi/table.c +++ b/dlls/msi/table.c @@ -396,6 +396,15 @@ end: return ret; } +static void free_table( MSITABLE *table ) +{ + int i; + for( i=0; irow_count; i++ ) + HeapFree( GetProcessHeap(), 0, table->data[i] ); + HeapFree( GetProcessHeap(), 0, table->data ); + HeapFree( GetProcessHeap(), 0, table ); +} + static UINT read_table_from_storage( MSIDATABASE *db, LPCWSTR name, MSITABLE **ptable) { MSITABLE *t; @@ -443,7 +452,10 @@ static UINT read_table_from_storage( MSIDATABASE *db, LPCWSTR name, MSITABLE **p t->data = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, t->row_count * sizeof (USHORT*) ); if( !t->data ) - return ERROR_NOT_ENOUGH_MEMORY; /* FIXME: memory leak */ + { + r = ERROR_NOT_ENOUGH_MEMORY; + goto err; + } /* transpose all the data */ TRACE("Transposing data from %d columns\n", t->row_count ); @@ -451,7 +463,10 @@ static UINT read_table_from_storage( MSIDATABASE *db, LPCWSTR name, MSITABLE **p { t->data[i] = HeapAlloc( GetProcessHeap(), 0, row_size ); if( !t->data[i] ) - return ERROR_NOT_ENOUGH_MEMORY; /* FIXME: memory leak */ + { + r = ERROR_NOT_ENOUGH_MEMORY; + goto err; + } for( j=0; jref_count ) { remove_table( db, table ); - HeapFree( GetProcessHeap(), 0, table->data ); - HeapFree( GetProcessHeap(), 0, table ); - TRACE("Destroyed table %s\n", debugstr_w(table->name)); + TRACE("Destroying table %s\n", debugstr_w(table->name)); + free_table( table ); } }