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>
This commit is contained in:
Dmitry Timoshkov 2018-04-26 17:17:33 +08:00 committed by Alexandre Julliard
parent 8d7d858d2b
commit ce57e5c4d7
1 changed files with 6 additions and 6 deletions

View File

@ -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, TRACE("trigger_offset %04x, triggers end at %04x\n", fixed->trigger_offset,
(DWORD)(fixed->trigger_offset + sizeof(USHORT) + trigger_count * sizeof(TASK_TRIGGER))); (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)); 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"); TRACE("no space for triggers data\n");
return SCHED_E_INVALID_TASK; 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; ITaskTrigger *trigger;
WORD idx; 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); size -= sizeof(USHORT) + trigger_count * sizeof(TASK_TRIGGER);
data += sizeof(USHORT) + This->trigger_count * sizeof(TASK_TRIGGER); data += sizeof(USHORT) + trigger_count * sizeof(TASK_TRIGGER);
if (size < 2 * sizeof(USHORT) + 64) if (size < 2 * sizeof(USHORT) + 64)
{ {