Skip to content

Commit

Permalink
Add check to avoid null pointer exception
Browse files Browse the repository at this point in the history
A bug can cause a segmentation fault. 
Add task ABC
Add task DEF
Set schedule of ABC to today.
Set schedule of DEF to today. This should cause a segmentation fault as the access after the i-- should point to an illegal address in this case.  Bug raised in issue meskio#10
  • Loading branch information
AlexTheAussieNerd authored Oct 8, 2023
1 parent ac50bd2 commit a797663
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ void Sched::add(pToDo todo)
{
if ((i != sched.end()) && ((*i)->sched() == todo->sched()))
{
for (; ((*i)->sched() == todo->sched()); i++);
i--;
todo->schedPosition() = (*i)->schedPosition() + 1;
i++;
if (i != sched.begin()){
for (; ((*i)->sched() == todo->sched()); i++);
i--;
todo->schedPosition() = (*i)->schedPosition() + 1;
i++;
}
}
else
{
Expand Down

0 comments on commit a797663

Please sign in to comment.