From 410610b55324da36146974128f89915577d1dfa6 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Thu, 16 Aug 2018 01:26:22 +0000 Subject: [PATCH] odbccp32: Handle NULL parameter in SQLWritePrivateProfileStringW. Signed-off-by: Alistair Leslie-Hughes Signed-off-by: Alexandre Julliard --- dlls/odbccp32/odbccp32.c | 6 +++++- dlls/odbccp32/tests/misc.c | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dlls/odbccp32/odbccp32.c b/dlls/odbccp32/odbccp32.c index 9420dceb30d..08645eb6c66 100644 --- a/dlls/odbccp32/odbccp32.c +++ b/dlls/odbccp32/odbccp32.c @@ -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); } diff --git a/dlls/odbccp32/tests/misc.c b/dlls/odbccp32/tests/misc.c index 8a16a9e8b9c..be3873acb6c 100644 --- a/dlls/odbccp32/tests/misc.c +++ b/dlls/odbccp32/tests/misc.c @@ -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)