Mike McCormack : msi: Make sure there' s a value for each column when inserting data.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Sep 7 05:07:10 CDT 2006


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

Author: Mike McCormack <mike at codeweavers.com>
Date:   Thu Aug 31 17:22:24 2006 +0900

msi: Make sure there's a value for each column when inserting data.

---

 dlls/msi/insert.c   |   14 +++++++++++++-
 dlls/msi/tests/db.c |    5 -----
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/dlls/msi/insert.c b/dlls/msi/insert.c
index eb65904..2b0f68a 100644
--- a/dlls/msi/insert.c
+++ b/dlls/msi/insert.c
@@ -234,6 +234,14 @@ static const MSIVIEWOPS insert_ops =
     INSERT_find_matching_rows
 };
 
+static UINT count_column_info( column_info *ci )
+{
+    UINT n = 0;
+    for ( ; ci; ci = ci->next )
+        n++;
+    return n;
+}
+
 UINT INSERT_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
                         column_info *columns, column_info *values, BOOL temp )
 {
@@ -243,6 +251,10 @@ UINT INSERT_CreateView( MSIDATABASE *db,
 
     TRACE("%p\n", iv );
 
+    /* there should be one value for each column */
+    if ( count_column_info( columns ) != count_column_info(values) )
+        return ERROR_BAD_QUERY_SYNTAX;
+
     r = TABLE_CreateView( db, table, &tv );
     if( r != ERROR_SUCCESS )
         return r;
@@ -254,7 +266,7 @@ UINT INSERT_CreateView( MSIDATABASE *db,
             tv->ops->delete( tv );
         return r;
     }
-    
+
     iv = msi_alloc_zero( sizeof *iv );
     if( !iv )
         return ERROR_FUNCTION_FAILED;
diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c
index a35b685..b61e643 100644
--- a/dlls/msi/tests/db.c
+++ b/dlls/msi/tests/db.c
@@ -162,17 +162,12 @@ static void test_msiinsert(void)
     r = do_query(hdb, query, &hrec);
     ok(r == ERROR_NO_MORE_ITEMS, "MsiViewFetch failed\n");
 
-    todo_wine {
     /* now try a few bad INSERT xqueries */
     query = "INSERT INTO `phone` ( `id`, `name`, `number` )"
         "VALUES(?, ?)";
     r = MsiDatabaseOpenView(hdb, query, &hview);
     ok(r == ERROR_BAD_QUERY_SYNTAX, "MsiDatabaseOpenView failed\n");
 
-    if (r == ERROR_SUCCESS)
-        r = MsiCloseHandle(hview);
-    }
-
     /* construct a record to insert */
     hrec = MsiCreateRecord(4);
     r = MsiRecordSetInteger(hrec, 1, 2);




More information about the wine-cvs mailing list