James Hawkins : msi: Successfully return an empty string when requesting a record index beyond the record 's size.
Alexandre Julliard
julliard at winehq.org
Mon Feb 11 14:19:32 CST 2008
Module: wine
Branch: master
Commit: 0d56df214bd88de0ddbe98bc08c95dfb8bece810
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0d56df214bd88de0ddbe98bc08c95dfb8bece810
Author: James Hawkins <truiken at gmail.com>
Date: Mon Feb 11 01:15:13 2008 -0600
msi: Successfully return an empty string when requesting a record index beyond the record's size.
---
dlls/msi/record.c | 16 ++++++++++++++--
dlls/msi/tests/record.c | 28 ++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/dlls/msi/record.c b/dlls/msi/record.c
index 8a69591..7a9c9e0 100644
--- a/dlls/msi/record.c
+++ b/dlls/msi/record.c
@@ -338,7 +338,13 @@ UINT MSI_RecordGetStringA(MSIRECORD *rec, UINT iField,
TRACE("%p %d %p %p\n", rec, iField, szValue, pcchValue);
if( iField > rec->count )
- return ERROR_INVALID_PARAMETER;
+ {
+ if ( szValue && *pcchValue > 0 )
+ szValue[0] = 0;
+
+ *pcchValue = 0;
+ return ERROR_SUCCESS;
+ }
ret = ERROR_SUCCESS;
switch( rec->fields[iField].type )
@@ -414,7 +420,13 @@ UINT MSI_RecordGetStringW(MSIRECORD *rec, UINT iField,
TRACE("%p %d %p %p\n", rec, iField, szValue, pcchValue);
if( iField > rec->count )
- return ERROR_INVALID_PARAMETER;
+ {
+ if ( szValue && *pcchValue > 0 )
+ szValue[0] = 0;
+
+ *pcchValue = 0;
+ return ERROR_SUCCESS;
+ }
ret = ERROR_SUCCESS;
switch( rec->fields[iField].type )
diff --git a/dlls/msi/tests/record.c b/dlls/msi/tests/record.c
index 1f72d12..471fc9c 100644
--- a/dlls/msi/tests/record.c
+++ b/dlls/msi/tests/record.c
@@ -351,7 +351,35 @@ static void test_msirecord(void)
DeleteFile(filename); /* Delete it for sure, when everything else is closed. */
}
+static void test_MsiRecordGetString(void)
+{
+ MSIHANDLE rec;
+ CHAR buf[MAX_PATH];
+ DWORD sz;
+ UINT r;
+
+ rec = MsiCreateRecord(2);
+ ok(rec != 0, "Expected a valid handle\n");
+
+ sz = MAX_PATH;
+ lstrcpyA(buf, "apple");
+ r = MsiRecordGetString(rec, 1, buf, &sz);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
+ ok(sz == 0, "Expected 0, got %d\n", sz);
+
+ sz = MAX_PATH;
+ lstrcpyA(buf, "apple");
+ r = MsiRecordGetString(rec, 10, buf, &sz);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
+ ok(sz == 0, "Expected 0, got %d\n", sz);
+
+ MsiCloseHandle(rec);
+}
+
START_TEST(record)
{
test_msirecord();
+ test_MsiRecordGetString();
}
More information about the wine-cvs
mailing list