From 557c3714e80c70b0d7140349e8ad330aa86e0eca Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Mon, 9 Nov 2015 12:22:27 +0800 Subject: [PATCH] taskschd/tests: Fix memory leaks (Valgrind). Signed-off-by: Dmitry Timoshkov Signed-off-by: Alexandre Julliard --- dlls/taskschd/task.c | 2 +- dlls/taskschd/tests/scheduler.c | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/dlls/taskschd/task.c b/dlls/taskschd/task.c index 5a7ade8e660..c33cda14c96 100644 --- a/dlls/taskschd/task.c +++ b/dlls/taskschd/task.c @@ -2611,8 +2611,8 @@ static HRESULT WINAPI TaskService_Connect(ITaskService *iface, VARIANT server, V hr = RpcStringBindingComposeW(NULL, ncalrpc, NULL, NULL, NULL, &binding_str); if (hr != RPC_S_OK) return hr; hr = RpcBindingFromStringBindingW(binding_str, &rpc_handle); - if (hr != RPC_S_OK) return hr; RpcStringFreeW(&binding_str); + if (hr != RPC_S_OK) return hr; /* Make sure that the connection works */ hr = SchRpcHighestVersion(&task_svc->version); diff --git a/dlls/taskschd/tests/scheduler.c b/dlls/taskschd/tests/scheduler.c index 9a745b89f13..60a6c94ce80 100644 --- a/dlls/taskschd/tests/scheduler.c +++ b/dlls/taskschd/tests/scheduler.c @@ -782,6 +782,7 @@ static void test_GetTask(void) { hr = ITaskFolder_DeleteTask(root, Wine_Task1, 0); ok(hr == S_OK, "DeleteTask error %#x\n", hr); + IRegisteredTask_Release(task1); } } @@ -809,8 +810,10 @@ todo_wine for (i = 0; i < sizeof(open_existing_task)/sizeof(open_existing_task[0]); i++) { - hr = ITaskFolder_RegisterTask(root, Wine_Task1, xmlW, open_existing_task[i].flags, v_null, v_null, TASK_LOGON_NONE, v_null, &task1); + hr = ITaskFolder_RegisterTask(root, Wine_Task1, xmlW, open_existing_task[i].flags, v_null, v_null, TASK_LOGON_NONE, v_null, &task2); ok(hr == open_existing_task[i].hr, "%d: expected %#x, got %#x\n", i, open_existing_task[i].hr, hr); + if (hr == S_OK) + IRegisteredTask_Release(task2); } hr = IRegisteredTask_get_Name(task1, NULL); @@ -944,6 +947,7 @@ todo_wine ok(hr == S_OK, "get_Name error %#x\n", hr); hr = IIDFromString(bstr, &iid); ok(hr == S_OK, "IIDFromString error %#x\n", hr); + SysFreeString(bstr); IRegisteredTask_Release(task1); @@ -1006,7 +1010,10 @@ static void test_settings_v1(ITaskDefinition *taskdef, struct settings *test, st if (!def->restart_interval[0]) ok(bstr == NULL, "expected NULL, got %s\n", wine_dbgstr_w(bstr)); else + { ok(!lstrcmpW(bstr, def->restart_interval), "expected %s, got %s\n", wine_dbgstr_w(def->restart_interval), wine_dbgstr_w(bstr)); + SysFreeString(bstr); + } hr = ITaskSettings_get_RestartCount(set, &vint); ok(hr == S_OK, "expected S_OK, got %#x\n", hr); @@ -1052,7 +1059,10 @@ static void test_settings_v1(ITaskDefinition *taskdef, struct settings *test, st if (!test->delete_expired_task_after[0]) ok(bstr == NULL, "expected NULL, got %s\n", wine_dbgstr_w(bstr)); else + { ok(!lstrcmpW(bstr, test->delete_expired_task_after), "expected %s, got %s\n", wine_dbgstr_w(test->delete_expired_task_after), wine_dbgstr_w(bstr)); + SysFreeString(bstr); + } hr = ITaskSettings_get_Priority(set, &vint); ok(hr == S_OK, "expected S_OK, got %#x\n", hr); @@ -1094,7 +1104,11 @@ static void change_settings(ITaskDefinition *taskdef, struct settings *test) todo_wine ok(hr == S_OK, "expected S_OK, got %#x\n", hr); /* FIXME: Remove once implemented */ - if (hr != S_OK) return; + if (hr != S_OK) + { + ITaskSettings_Release(set); + return; + } hr = ITaskSettings_put_RestartCount(set, test->restart_count); ok(hr == S_OK, "expected S_OK, got %#x\n", hr);