Roy Shea roy@cs.hmc.edu writes:
+/* Allocate and initializes an ANSI version of the Unicode string */ +static LPSTR UnicodeToAnsi(const WCHAR *unicode) +{
- int size;
- LPSTR ansi;
- size = WideCharToMultiByte(CP_UTF8, 0, unicode, -1, NULL, 0, NULL, NULL);
- ansi = HeapAlloc(GetProcessHeap(), 0, size);
- WideCharToMultiByte(CP_UTF8, 0, unicode, -1, ansi, size, NULL, NULL);
- return ansi;
+}
UTF-8 is not the same thing as ANSI, this function is misleading. For procedure names what you probably want is a special-purpose function that rejects anything that isn't 7-bit ASCII.
- ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE, service_param_key, 0,
KEY_READ, &service_hkey);
- if (ret != ERROR_SUCCESS)
- {
WINE_ERR("cannot open key %s, err=%d\n",
wine_dbgstr_w(service_param_key), ret);
HeapFree(GetProcessHeap(), 0, service_param_key);
return FALSE;
- }
- /* Find DLL associate with service from key */
- dll_name_short = GetRegValue(service_hkey, service_dll);
- if (!dll_name_short)
- {
WINE_ERR("cannot find registry value %s for service %s\n",
wine_dbgstr_w(service_dll), wine_dbgstr_w(service_name));
HeapFree(GetProcessHeap(), 0, service_param_key);
return FALSE;
- }
You are leaking registry handles pretty much everywhere.