Lionel Debroux : msi: Correctly handle return value of msi_realloc.

Alexandre Julliard julliard at winehq.org
Wed Jan 2 07:34:46 CST 2008


Module: wine
Branch: master
Commit: 99ad76c3c18a7437f6abe4815ec2c572a0fffa03
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=99ad76c3c18a7437f6abe4815ec2c572a0fffa03

Author: Lionel Debroux <lionel_debroux at yahoo.fr>
Date:   Sun Dec 30 19:01:09 2007 +0100

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 4d71822..b1841f7 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 a690ee4..f3022f4 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);
     }




More information about the wine-cvs mailing list