From 99ad76c3c18a7437f6abe4815ec2c572a0fffa03 Mon Sep 17 00:00:00 2001 From: Lionel Debroux Date: Sun, 30 Dec 2007 19:01:09 +0100 Subject: [PATCH] msi: Correctly handle return value of msi_realloc. --- dlls/msi/action.c | 10 +++++++--- dlls/msi/database.c | 20 ++++++++++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/dlls/msi/action.c b/dlls/msi/action.c index 4d7182267a1..b1841f77c68 100644 --- a/dlls/msi/action.c +++ b/dlls/msi/action.c @@ -4482,7 +4482,7 @@ static UINT ACTION_InstallServices( MSIPACKAGE *package ) /* converts arg1[~]arg2[~]arg3 to a list of ptrs to the strings */ static LPCWSTR *msi_service_args_to_vector(LPWSTR args, DWORD *numargs) { - LPCWSTR *vector; + LPCWSTR *vector, *temp_vector; LPWSTR p, q; DWORD sep_len; @@ -4508,9 +4508,13 @@ static LPCWSTR *msi_service_args_to_vector(LPWSTR args, DWORD *numargs) { *q = '\0'; - vector = msi_realloc(vector, (*numargs + 1) * sizeof(LPWSTR)); - if (!vector) + temp_vector = msi_realloc(vector, (*numargs + 1) * sizeof(LPWSTR)); + if (!temp_vector) + { + msi_free(vector); return NULL; + } + vector = temp_vector; p = q + sep_len; } diff --git a/dlls/msi/database.c b/dlls/msi/database.c index a690ee449cc..f3022f44671 100644 --- a/dlls/msi/database.c +++ b/dlls/msi/database.c @@ -353,7 +353,7 @@ static LPWSTR msi_build_createsql_prelude(LPWSTR table) static LPWSTR msi_build_createsql_columns(LPWSTR *columns_data, LPWSTR *types, DWORD num_columns) { - LPWSTR columns; + LPWSTR columns, p; LPCWSTR type; DWORD sql_size = 1, i, len; WCHAR expanded[128], *ptr; @@ -413,9 +413,13 @@ static LPWSTR msi_build_createsql_columns(LPWSTR *columns_data, LPWSTR *types, D sprintfW(expanded, column_fmt, columns_data[i], type, size, extra, comma); sql_size += lstrlenW(expanded); - columns = msi_realloc(columns, sql_size * sizeof(WCHAR)); - if (!columns) + p = msi_realloc(columns, sql_size * sizeof(WCHAR)); + if (!p) + { + msi_free(columns); return NULL; + } + columns = p; lstrcatW(columns, expanded); } @@ -519,7 +523,7 @@ static LPWSTR msi_build_insertsql_prelude(LPWSTR table) static LPWSTR msi_build_insertsql_columns(LPWSTR *columns_data, LPWSTR *types, DWORD num_columns) { - LPWSTR columns; + LPWSTR columns, p; DWORD sql_size = 1, i; WCHAR expanded[128]; @@ -540,9 +544,13 @@ static LPWSTR msi_build_insertsql_columns(LPWSTR *columns_data, LPWSTR *types, D expanded[lstrlenW(expanded) - 2] = '\0'; } - columns = msi_realloc(columns, sql_size * sizeof(WCHAR)); - if (!columns) + p = msi_realloc(columns, sql_size * sizeof(WCHAR)); + if (!p) + { + msi_free(columns); return NULL; + } + columns = p; lstrcatW(columns, expanded); }