8000 Fix crash Stop and pNext (#15) · useful-esp8266-lib/Task@399f110 · GitHub
[go: up one dir, main page]

Skip to content

Commit 399f110

Browse files
rudacsMakuna
authored andcommitted
Fix crash Stop and pNext (Makuna#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.
1 parent 91995db commit 399f110

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Task.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class Task
5757
Task(uint32_t timeInterval) :
5858
_timeInterval(timeInterval),
5959
_remainingTime(0),
60-
_taskState(TaskState_Stopped)
60+
_taskState(TaskState_Stopped),
61+
_pNext(NULL)
6162
{
6263
}
6364

@@ -102,8 +103,11 @@ class Task
102103
}
103104
void Stop()
104105
{
105-
OnStop();
106-
_taskState = TaskState_Stopping;
106+
if (_taskState == TaskState_Running)
107+
{
108+
OnStop();
109+
_taskState = TaskState_Stopping;
110+
}
107111
}
108112
};
109113

0 commit comments

Comments
 (0)
0