msi: Test MsiRecordGetString on an integer record fields with a NULL output buffer.

This commit is contained in:
Mike McCormack 2006-11-21 15:21:27 +09:00 committed by Alexandre Julliard
parent 99129d20a6
commit 8f20756068
2 changed files with 16 additions and 4 deletions

View File

@ -346,6 +346,7 @@ UINT MSI_RecordGetStringA(MSIRECORD *rec, unsigned int iField,
case MSIFIELD_INT:
wsprintfA(buffer, "%d", rec->fields[iField].u.iVal);
len = lstrlenA( buffer );
if (szValue)
lstrcpynA(szValue, buffer, *pcchValue);
break;
case MSIFIELD_WSTR:
@ -421,10 +422,12 @@ UINT MSI_RecordGetStringW(MSIRECORD *rec, unsigned int iField,
case MSIFIELD_INT:
wsprintfW(buffer, szFormat, rec->fields[iField].u.iVal);
len = lstrlenW( buffer );
if (szValue)
lstrcpynW(szValue, buffer, *pcchValue);
break;
case MSIFIELD_WSTR:
len = lstrlenW( rec->fields[iField].u.szwVal );
if (szValue)
lstrcpynW(szValue, rec->fields[iField].u.szwVal, *pcchValue);
break;
case MSIFIELD_NULL:

View File

@ -250,6 +250,10 @@ static void test_msirecord(void)
/* same record, try converting integers to strings */
r = MsiRecordSetInteger(h, 0, 32);
ok(r == ERROR_SUCCESS, "Failed to set integer at 0 to 32\n");
sz = 1;
r = MsiRecordGetString(h, 0, NULL, &sz);
ok(r == ERROR_SUCCESS, "failed to get string from integer\n");
ok(sz == 2, "length wrong\n");
buf[0]=0;
sz = sizeof buf;
r = MsiRecordGetString(h, 0, buf, &sz);
@ -258,10 +262,15 @@ static void test_msirecord(void)
r = MsiRecordSetInteger(h, 0, -32);
ok(r == ERROR_SUCCESS, "Failed to set integer at 0 to 32\n");
buf[0]=0;
sz = 1;
r = MsiRecordGetString(h, 0, NULL, &sz);
ok(r == ERROR_SUCCESS, "failed to get string from integer\n");
ok(sz == 3, "length wrong\n");
sz = sizeof buf;
r = MsiRecordGetString(h, 0, buf, &sz);
ok(r == ERROR_SUCCESS, "failed to get string from integer\n");
ok(0==strcmp(buf,"-32"), "failed to get string from integer\n");
buf[0]=0;
/* same record, now try streams */
r = MsiRecordSetStream(h, 0, NULL);