odbccp32: Correcly lookup driver in load_config_driver.

RegGetValueW doesn't return ERROR_MORE_DATA when the buffer parameter
is NULL, unlike other Reg functions. This also passes the correct
parameter(reg_driver) on the second call to RegGetValueW.

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:21 +00:00 committed by Alexandre Julliard
parent 410610b553
commit 7973699a8b
1 changed files with 16 additions and 10 deletions

View File

@ -259,20 +259,26 @@ static HMODULE load_config_driver(const WCHAR *driver)
if ((ret = RegOpenKeyW(hkey, driver, &hkeydriver)) == ERROR_SUCCESS)
{
ret = RegGetValueW(hkeydriver, NULL, reg_driver, RRF_RT_REG_SZ, &type, NULL, &size);
if(ret == ERROR_MORE_DATA)
if(ret != ERROR_SUCCESS || type != REG_SZ)
{
filename = HeapAlloc(GetProcessHeap(), 0, size);
if(!filename)
{
RegCloseKey(hkeydriver);
RegCloseKey(hkey);
push_error(ODBC_ERROR_OUT_OF_MEM, odbc_error_out_of_mem);
RegCloseKey(hkeydriver);
RegCloseKey(hkey);
push_error(ODBC_ERROR_INVALID_DSN, odbc_error_invalid_dsn);
return NULL;
}
ret = RegGetValueW(hkeydriver, NULL, driver, RRF_RT_REG_SZ, &type, filename, &size);
return NULL;
}
filename = HeapAlloc(GetProcessHeap(), 0, size);
if(!filename)
{
RegCloseKey(hkeydriver);
RegCloseKey(hkey);
push_error(ODBC_ERROR_OUT_OF_MEM, odbc_error_out_of_mem);
return NULL;
}
ret = RegGetValueW(hkeydriver, NULL, reg_driver, RRF_RT_REG_SZ, &type, filename, &size);
RegCloseKey(hkeydriver);
}