Zebediah Figura : msi: Allow setting NULL in MsiSetInteger().

Alexandre Julliard julliard at winehq.org
Mon Jul 10 15:52:46 CDT 2017


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

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Fri Jul  7 09:03:13 2017 -0500

msi: Allow setting NULL in MsiSetInteger().

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msi/record.c       | 13 +++++++++++--
 dlls/msi/tests/record.c | 19 +++++++++++++++++--
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/dlls/msi/record.c b/dlls/msi/record.c
index 51e7a23..39ef70f 100644
--- a/dlls/msi/record.c
+++ b/dlls/msi/record.c
@@ -333,8 +333,17 @@ UINT MSI_RecordSetInteger( MSIRECORD *rec, UINT iField, int iVal )
         return ERROR_INVALID_PARAMETER;
 
     MSI_FreeField( &rec->fields[iField] );
-    rec->fields[iField].type = MSIFIELD_INT;
-    rec->fields[iField].u.iVal = iVal;
+
+    if (iVal == MSI_NULL_INTEGER)
+    {
+        rec->fields[iField].type = MSIFIELD_NULL;
+        rec->fields[iField].u.szwVal = NULL;
+    }
+    else
+    {
+        rec->fields[iField].type = MSIFIELD_INT;
+        rec->fields[iField].u.iVal = iVal;
+    }
 
     return ERROR_SUCCESS;
 }
diff --git a/dlls/msi/tests/record.c b/dlls/msi/tests/record.c
index 38d0f76..5caaefc 100644
--- a/dlls/msi/tests/record.c
+++ b/dlls/msi/tests/record.c
@@ -162,6 +162,21 @@ static void test_msirecord(void)
     ok(bufW[0] == 0, "MsiRecordGetStringW returned the wrong string\n");
     ok(sz == 0, "MsiRecordGetStringW returned the wrong length\n");
 
+    /* same record, but add a null integer to it */
+    r = MsiRecordSetInteger(h, 0, 1);
+    ok(r == ERROR_SUCCESS, "Failed to set integer at 0\n");
+    r = MsiRecordIsNull(h, 0);
+    ok(r == FALSE, "expected field to be non-null\n");
+    r = MsiRecordSetInteger(h, 0, MSI_NULL_INTEGER);
+    ok(r == ERROR_SUCCESS, "Failed to set integer at 0\n");
+    r = MsiRecordIsNull(h, 0);
+    ok(r == TRUE, "expected field to be null\n");
+    sz = sizeof buf;
+    r = MsiRecordGetStringA(h, 0, buf, &sz);
+    ok(r == ERROR_SUCCESS, "Failed to get string at 0\n");
+    ok(buf[0] == 0, "MsiRecordGetStringA returned the wrong string\n");
+    ok(sz == 0, "MsiRecordGetStringA returned the wrong length\n");
+
     /* same record, but add a string to it */
     r = MsiRecordSetStringA(h,0,str);
     ok(r == ERROR_SUCCESS, "Failed to set string at 0\n");
@@ -431,7 +446,7 @@ static void test_MsiRecordGetString(void)
     r = MsiRecordGetStringA(rec, 1, buf, &sz);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
     ok(!lstrcmpA(buf, "5"), "Expected \"5\", got \"%s\"\n", buf);
-    ok(sz == 1, "Expectd 1, got %d\n", sz);
+    ok(sz == 1, "Expected 1, got %d\n", sz);
 
     r = MsiRecordSetInteger(rec, 1, -5);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
@@ -441,7 +456,7 @@ static void test_MsiRecordGetString(void)
     r = MsiRecordGetStringA(rec, 1, buf, &sz);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
     ok(!lstrcmpA(buf, "-5"), "Expected \"-5\", got \"%s\"\n", buf);
-    ok(sz == 2, "Expectd 2, got %d\n", sz);
+    ok(sz == 2, "Expected 2, got %d\n", sz);
 
     MsiCloseHandle(rec);
 }




More information about the wine-cvs mailing list