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 --- dlls/odbccp32/odbccp32.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/dlls/odbccp32/odbccp32.c b/dlls/odbccp32/odbccp32.c index be68e6a..64f366a 100644 --- a/dlls/odbccp32/odbccp32.c +++ b/dlls/odbccp32/odbccp32.c @@ -235,19 +235,25 @@ 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); }