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

This commit is contained in:
James Hawkins 2008-02-11 01:15:13 -06:00 committed by Alexandre Julliard
parent 2750ed167f
commit 0d56df214b
2 changed files with 42 additions and 2 deletions

View File

@ -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 )

View File

@ -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();
}