Module: wine Branch: master Commit: 410610b55324da36146974128f89915577d1dfa6 URL: https://source.winehq.org/git/wine.git/?a=commit;h=410610b55324da36146974128...
Author: Alistair Leslie-Hughes leslie_alistair@hotmail.com Date: Thu Aug 16 01:26:22 2018 +0000
odbccp32: Handle NULL parameter in SQLWritePrivateProfileStringW.
Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
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 9420dce..08645eb 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 8a16a9e..be3873ac 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)