Commit 3804b99e authored by Sven Baars's avatar Sven Baars Committed by Alexandre Julliard

mstask: Fix some memory leaks on error path (Valgrind).

parent 48e6f8f9
...@@ -1690,7 +1690,11 @@ static HRESULT WINAPI MSTASK_IPersistFile_Save(IPersistFile *iface, LPCOLESTR ta ...@@ -1690,7 +1690,11 @@ static HRESULT WINAPI MSTASK_IPersistFile_Save(IPersistFile *iface, LPCOLESTR ta
hfile = CreateFileW(task_name, GENERIC_READ | GENERIC_WRITE, 0, NULL, disposition, 0, 0); hfile = CreateFileW(task_name, GENERIC_READ | GENERIC_WRITE, 0, NULL, disposition, 0, 0);
if (hfile != INVALID_HANDLE_VALUE) break; if (hfile != INVALID_HANDLE_VALUE) break;
if (try++ >= 3) return HRESULT_FROM_WIN32(GetLastError()); if (try++ >= 3)
{
hr = HRESULT_FROM_WIN32(GetLastError());
goto failed;
}
Sleep(100); Sleep(100);
} }
...@@ -1781,13 +1785,16 @@ failed: ...@@ -1781,13 +1785,16 @@ failed:
CoTaskMemFree(comment); CoTaskMemFree(comment);
CoTaskMemFree(user_data); CoTaskMemFree(user_data);
CloseHandle(hfile); if (hfile != INVALID_HANDLE_VALUE)
if (hr != S_OK)
DeleteFileW(task_name);
else if (remember)
{ {
heap_free(This->task_name); CloseHandle(hfile);
This->task_name = heap_strdupW(task_name); if (hr != S_OK)
DeleteFileW(task_name);
else if (remember)
{
heap_free(This->task_name);
This->task_name = heap_strdupW(task_name);
}
} }
return hr; return hr;
} }
......
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