[PATCH 4/6] msi: Allow setting NULL in MsiSetInteger().
Zebediah Figura
z.figura12 at gmail.com
Thu Jul 6 22:37:04 CDT 2017
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
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);
}
--
2.7.4
More information about the wine-patches
mailing list