From ce57e5c4d7bd7e525464840dcfe2af84acc372b5 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 26 Apr 2018 17:17:33 +0800
Subject: [PATCH] mstask: Correctly initialize trigger count when loading a
 task.

Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
---
 dlls/mstask/task.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/dlls/mstask/task.c b/dlls/mstask/task.c
index 86721047680..f93aff1ccbd 100644
--- a/dlls/mstask/task.c
+++ b/dlls/mstask/task.c
@@ -968,17 +968,17 @@ static HRESULT load_job_data(TaskImpl *This, BYTE *data, DWORD size)
     TRACE("trigger_offset %04x, triggers end at %04x\n", fixed->trigger_offset,
           (DWORD)(fixed->trigger_offset + sizeof(USHORT) + trigger_count * sizeof(TASK_TRIGGER)));
 
-    This->trigger_count = *(const USHORT *)data;
-    TRACE("trigger_count %u\n", trigger_count);
     task_trigger = (TASK_TRIGGER *)(data + sizeof(USHORT));
 
-    if (This->trigger_count * sizeof(TASK_TRIGGER) > triggers_size)
+    if (trigger_count * sizeof(TASK_TRIGGER) > triggers_size)
     {
         TRACE("no space for triggers data\n");
         return SCHED_E_INVALID_TASK;
     }
 
-    for (i = 0; i < This->trigger_count; i++)
+    This->trigger_count = 0;
+
+    for (i = 0; i < trigger_count; i++)
     {
         ITaskTrigger *trigger;
         WORD idx;
@@ -995,8 +995,8 @@ static HRESULT load_job_data(TaskImpl *This, BYTE *data, DWORD size)
         }
     }
 
-    size -= sizeof(USHORT) + This->trigger_count * sizeof(TASK_TRIGGER);
-    data += sizeof(USHORT) + This->trigger_count * sizeof(TASK_TRIGGER);
+    size -= sizeof(USHORT) + trigger_count * sizeof(TASK_TRIGGER);
+    data += sizeof(USHORT) + trigger_count * sizeof(TASK_TRIGGER);
 
     if (size < 2 * sizeof(USHORT) + 64)
     {