From e495e7e34cd2b07010dd1592186b02f0ba4ab558 Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Mon, 31 Jan 2005 11:30:59 +0000 Subject: [PATCH] Setting a record to an empty string is the same as making it null. --- dlls/msi/record.c | 4 ++-- dlls/msi/tests/record.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dlls/msi/record.c b/dlls/msi/record.c index cccbbfdcc16..c721e25d407 100644 --- a/dlls/msi/record.c +++ b/dlls/msi/record.c @@ -455,7 +455,7 @@ UINT MSI_RecordSetStringA( MSIRECORD *rec, unsigned int iField, LPCSTR szValue ) return ERROR_INVALID_FIELD; MSI_FreeField( &rec->fields[iField] ); - if( szValue ) + if( szValue && szValue[0] ) { len = MultiByteToWideChar( CP_ACP, 0, szValue, -1, NULL, 0 ); str = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) ); @@ -501,7 +501,7 @@ UINT MSI_RecordSetStringW( MSIRECORD *rec, unsigned int iField, LPCWSTR szValue MSI_FreeField( &rec->fields[iField] ); - if( szValue ) + if( szValue && szValue[0] ) { len = lstrlenW(szValue) + 1; str = HeapAlloc( GetProcessHeap(), 0, len*sizeof (WCHAR)); diff --git a/dlls/msi/tests/record.c b/dlls/msi/tests/record.c index d0054dc23f6..2d900b8b639 100644 --- a/dlls/msi/tests/record.c +++ b/dlls/msi/tests/record.c @@ -123,6 +123,10 @@ void test_msirecord(void) ok(r == ERROR_SUCCESS, "Failed to set null string at 0\n"); r = MsiRecordIsNull(h, 0); ok(r == TRUE, "null string not null field\n"); + r = MsiRecordSetString(h, 0, ""); + ok(r == ERROR_SUCCESS, "Failed to set empty string at 0\n"); + r = MsiRecordIsNull(h, 0); + ok(r == TRUE, "null string not null field\n"); r = MsiRecordSetString(h,0,str); ok(r == ERROR_SUCCESS, "Failed to set string at 0\n"); r = MsiRecordGetInteger(h, 0);