Commit 0d56df21 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

msi: Successfully return an empty string when requesting a record index beyond the record's size.

parent 2750ed16
......@@ -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 )
......
......@@ -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();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment