odbccp32: Handle NULL parameter in SQLWritePrivateProfileStringW.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alistair Leslie-Hughes 2018-08-16 01:26:22 +00:00 committed by Alexandre Julliard
parent d94de38f45
commit 410610b553
2 changed files with 8 additions and 1 deletions

View File

@ -1561,6 +1561,7 @@ BOOL WINAPI SQLWriteFileDSN(LPCSTR lpszFileName, LPCSTR lpszAppName,
BOOL WINAPI SQLWritePrivateProfileStringW(LPCWSTR lpszSection, LPCWSTR lpszEntry,
LPCWSTR lpszString, LPCWSTR lpszFilename)
{
static const WCHAR empty[] = {0};
LONG ret;
HKEY hkey;
@ -1584,7 +1585,10 @@ BOOL WINAPI SQLWritePrivateProfileStringW(LPCWSTR lpszSection, LPCWSTR lpszEntry
if ((ret = RegCreateKeyW(hkeyfilename, lpszSection, &hkey_section)) == ERROR_SUCCESS)
{
ret = RegSetValueExW(hkey_section, lpszEntry, 0, REG_SZ, (BYTE*)lpszString, (lstrlenW(lpszString)+1)*sizeof(WCHAR));
if(lpszString)
ret = RegSetValueExW(hkey_section, lpszEntry, 0, REG_SZ, (BYTE*)lpszString, (lstrlenW(lpszString)+1)*sizeof(WCHAR));
else
ret = RegSetValueExW(hkey_section, lpszEntry, 0, REG_SZ, (BYTE*)empty, sizeof(empty));
RegCloseKey(hkey_section);
}

View File

@ -171,6 +171,9 @@ static void test_SQLWritePrivateProfileString(void)
{
HKEY hkey;
ret = SQLWritePrivateProfileString("wineodbc", "testing" , NULL, "odbc.ini");
ok(ret, "SQLWritePrivateProfileString failed\n");
reg_ret = RegOpenKeyExW(HKEY_CURRENT_USER, odbc_key, 0, KEY_READ, &hkey);
ok(reg_ret == ERROR_SUCCESS, "RegOpenKeyExW failed\n");
if(reg_ret == ERROR_SUCCESS)