Sven Baars : mstask: Fix some memory leaks on error path (Valgrind).
Alexandre Julliard
julliard at winehq.org
Wed May 15 14:32:23 CDT 2019
Module: wine
Branch: stable
Commit: cf05d6679d770316c14129c1efa744778157ef4e
URL: https://source.winehq.org/git/wine.git/?a=commit;h=cf05d6679d770316c14129c1efa744778157ef4e
Author: Sven Baars <sven.wine at gmail.com>
Date: Wed Feb 6 11:48:18 2019 +0100
mstask: Fix some memory leaks on error path (Valgrind).
Signed-off-by: Sven Baars <sven.wine at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 3804b99e7253a13b383549a6a851e80300841cc5)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/mstask/task.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/dlls/mstask/task.c b/dlls/mstask/task.c
index 6c27b76..9a39fc9 100644
--- a/dlls/mstask/task.c
+++ b/dlls/mstask/task.c
@@ -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);
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);
}
@@ -1781,13 +1785,16 @@ failed:
CoTaskMemFree(comment);
CoTaskMemFree(user_data);
- CloseHandle(hfile);
- if (hr != S_OK)
- DeleteFileW(task_name);
- else if (remember)
+ if (hfile != INVALID_HANDLE_VALUE)
{
- heap_free(This->task_name);
- This->task_name = heap_strdupW(task_name);
+ CloseHandle(hfile);
+ if (hr != S_OK)
+ DeleteFileW(task_name);
+ else if (remember)
+ {
+ heap_free(This->task_name);
+ This->task_name = heap_strdupW(task_name);
+ }
}
return hr;
}
More information about the wine-cvs
mailing list