luni64 / TeensyTimerTool

Generic Interface to Teensy Timers
MIT License
82 stars 18 forks source link

Protect unsafe usage of `BaseTimer::start` and `BaseTimer::stop` #7

Closed korhadris closed 2 years ago

korhadris commented 3 years ago

I know I shouldn't be doing this, but I noticed that BaseTimer::start and BaseTimer::stop use the timerChannel pointer without checking them; I would expect them to return errorCode::notInitialized if it isn't set yet.

Test to reproduce crashes:

#include <TeensyTimerTool.h>

TeensyTimerTool::PeriodicTimer t1;

void begin() {
  t1.start();  // Dies here without progressing (expected seg fault)
  // Rest of code
}
korhadris commented 3 years ago

I don't mind making a PR for this change if wanted too...

luni64 commented 3 years ago

Thanks for spotting this. I'll fix it later today

luni64 commented 2 years ago

Done in https://github.com/luni64/TeensyTimerTool/commit/7eab51926f3d5ef96103bef7fd1741c6f6b7415f