odbccp32: Implement SQLGetPrivateProfileString (try 6 - resend)
+ LONG ret = 0; + HKEY hkey; + DWORD size = 0; + BOOL usedefault = TRUE; + /* snip */ + clear_errors(); + + if(!cbRetBuffer) + return 0; + + if(RetBuffer) + RetBuffer[0] = 0; + + if(!lpszSection || !lpszEntry || !lpszDefault || !RetBuffer || !cbRetBuffer) + return ret;
You are checking "if (!cbRetBuffer)" twice. Same in the next function. You don't need to clear RetBuffer. RegGetValue adds a null terminating character if it doesn't already exist. You also "return 0" and "return ret". They are the same at the moment, so be consistent.
+size = cbRetBuffer; +if(RegGetValueW(hkeysect, NULL, lpszEntry, RRF_RT_REG_SZ, &type, RetBuffer, &size) == ERROR_SUCCESS)
cbRetBuffer is the size in characters of the buffer pointed to by RetBuffer.[1] size needs to be in bytes, so unless RetBuffer uses char, this is wrong.
+ ret = SQLGetPrivateProfileStringW(sect, entry, string, retval, cbRetBuffer, file); + if(ret) + { + WideCharToMultiByte(CP_ACP, 0, retval, -1, RetBuffer, ret+1, NULL, NULL); + }
This doesn't look right to me. "ret+1" should be the size, in bytes, of RetBuffer. [2] [1] https://msdn.microsoft.com/en-us/library/windows/desktop/ms724868%28v=vs.85%... [2] https://msdn.microsoft.com/en-us/library/windows/desktop/dd374130%28v=vs.85%...
participants (1)
-
Hugh McMaster