Commit 8f207560 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

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

parent 99129d20
......@@ -273,7 +273,7 @@ UINT MSI_RecordSetInteger( MSIRECORD *rec, unsigned int iField, int iVal )
if( iField > rec->count )
return ERROR_INVALID_PARAMETER;
MSI_FreeField( &rec->fields[iField] );
rec->fields[iField].type = MSIFIELD_INT;
rec->fields[iField].u.iVal = iVal;
......@@ -346,7 +346,8 @@ UINT MSI_RecordGetStringA(MSIRECORD *rec, unsigned int iField,
case MSIFIELD_INT:
wsprintfA(buffer, "%d", rec->fields[iField].u.iVal);
len = lstrlenA( buffer );
lstrcpynA(szValue, buffer, *pcchValue);
if (szValue)
lstrcpynA(szValue, buffer, *pcchValue);
break;
case MSIFIELD_WSTR:
len = WideCharToMultiByte( CP_ACP, 0, rec->fields[iField].u.szwVal, -1,
......@@ -421,11 +422,13 @@ UINT MSI_RecordGetStringW(MSIRECORD *rec, unsigned int iField,
case MSIFIELD_INT:
wsprintfW(buffer, szFormat, rec->fields[iField].u.iVal);
len = lstrlenW( buffer );
lstrcpynW(szValue, buffer, *pcchValue);
if (szValue)
lstrcpynW(szValue, buffer, *pcchValue);
break;
case MSIFIELD_WSTR:
len = lstrlenW( rec->fields[iField].u.szwVal );
lstrcpynW(szValue, rec->fields[iField].u.szwVal, *pcchValue);
if (szValue)
lstrcpynW(szValue, rec->fields[iField].u.szwVal, *pcchValue);
break;
case MSIFIELD_NULL:
len = 1;
......
......@@ -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);
......
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