From b530f38baa571738d061b38f62db6c63465f8619 Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Tue, 15 Dec 2009 18:19:25 -0800 Subject: [PATCH] msi: Refactor freeing the import sql strings. --- dlls/msi/database.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/dlls/msi/database.c b/dlls/msi/database.c index 3896454cb34..6ce516a78db 100644 --- a/dlls/msi/database.c +++ b/dlls/msi/database.c @@ -493,10 +493,10 @@ done: static UINT msi_add_table_to_db(MSIDATABASE *db, LPWSTR *columns, LPWSTR *types, LPWSTR *labels, DWORD num_labels, DWORD num_columns) { - UINT r; + UINT r = ERROR_OUTOFMEMORY; DWORD size; MSIQUERY *view; - LPWSTR create_sql; + LPWSTR create_sql = NULL; LPWSTR prelude, columns_sql, postlude; prelude = msi_build_createsql_prelude(labels[0]); @@ -504,31 +504,30 @@ static UINT msi_add_table_to_db(MSIDATABASE *db, LPWSTR *columns, LPWSTR *types, postlude = msi_build_createsql_postlude(labels + 1, num_labels - 1); /* skip over table name */ if (!prelude || !columns_sql || !postlude) - return ERROR_OUTOFMEMORY; + goto done; size = lstrlenW(prelude) + lstrlenW(columns_sql) + lstrlenW(postlude) + 1; create_sql = msi_alloc(size * sizeof(WCHAR)); if (!create_sql) - return ERROR_OUTOFMEMORY; + goto done; lstrcpyW(create_sql, prelude); lstrcatW(create_sql, columns_sql); lstrcatW(create_sql, postlude); - msi_free(prelude); - msi_free(columns_sql); - msi_free(postlude); - r = MSI_DatabaseOpenViewW( db, create_sql, &view ); - msi_free(create_sql); - if (r != ERROR_SUCCESS) - return r; + goto done; r = MSI_ViewExecute(view, NULL); MSI_ViewClose(view); msiobj_release(&view->hdr); +done: + msi_free(prelude); + msi_free(columns_sql); + msi_free(postlude); + msi_free(create_sql); return r; }