From 399f11086685c6703a42fc6e10f5640f0f359eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rud=C3=A1=20Cunha?= Date: Mon, 27 Feb 2017 06:11:26 -0300 Subject: [PATCH] Fix crash Stop and pNext (#15) Crash occurs if you make a Stop and then a Start. Then you should check if it's really running. Set NULL in pNext pointer to avoid junk. --- src/Task.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Task.h b/src/Task.h index 95cd9b1..d8183b0 100644 --- a/src/Task.h +++ b/src/Task.h @@ -57,7 +57,8 @@ class Task Task(uint32_t timeInterval) : _timeInterval(timeInterval), _remainingTime(0), - _taskState(TaskState_Stopped) + _taskState(TaskState_Stopped), + _pNext(NULL) { } @@ -102,8 +103,11 @@ class Task } void Stop() { - OnStop(); - _taskState = TaskState_Stopping; + if (_taskState == TaskState_Running) + { + OnStop(); + _taskState = TaskState_Stopping; + } } };