Commit ecc850c4 authored by Dimitrie O. Paun's avatar Dimitrie O. Paun Committed by Alexandre Julliard

Fix a memory leak in toolbar. Avoid casts.

parent 1ef206de
......@@ -4527,23 +4527,33 @@ TOOLBAR_SaveRestoreW (HWND hwnd, WPARAM wParam, LPTBSAVEPARAMSW lpSave)
static LRESULT
TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPTBSAVEPARAMSA lpSave)
{
LPWSTR pszValueName = 0, pszSubKey = 0;
TBSAVEPARAMSW SaveW;
LRESULT result = 0;
int len;
if (lpSave == NULL) return 0;
SaveW.hkr = lpSave->hkr;
len = MultiByteToWideChar(CP_ACP, 0, lpSave->pszSubKey, -1, NULL, 0);
SaveW.pszSubKey = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, lpSave->pszSubKey, -1, (LPWSTR)SaveW.pszSubKey, len);
pszSubKey = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
if (pszSubKey) goto exit;
MultiByteToWideChar(CP_ACP, 0, lpSave->pszSubKey, -1, pszSubKey, len);
len = MultiByteToWideChar(CP_ACP, 0, lpSave->pszValueName, -1, NULL, 0);
SaveW.pszValueName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, lpSave->pszValueName, -1, (LPWSTR)SaveW.pszValueName, len);
pszValueName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
if (!pszValueName) goto exit;
MultiByteToWideChar(CP_ACP, 0, lpSave->pszValueName, -1, pszValueName, len);
SaveW.pszValueName = pszValueName;
SaveW.pszSubKey = pszSubKey;
SaveW.hkr = lpSave->hkr;
result = TOOLBAR_SaveRestoreW(hwnd, wParam, &SaveW);
exit:
HeapFree(GetProcessHeap(), 0, pszValueName);
HeapFree(GetProcessHeap(), 0, pszSubKey);
/* FIXME: shoudn't we free the HeapAlloc()ed memory? */
return TOOLBAR_SaveRestoreW(hwnd, wParam, &SaveW);
return result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment