Fix sleep lock underflow in LowPowerTimer

If a LowPowerTimer is started and then goes out of scope then a
deep sleep lock underflow can occur. This is because the
the variable '_lock_deepsleep' is checked when starting the timer
but is not checked in the destructor, which unconditionally releases
the deep sleep lock.
pull/5242/head
Russ Butler 2017-10-02 19:32:20 -05:00
parent c60194fdfd
commit 32303a9130
1 changed files with 3 additions and 1 deletions

View File

@ -35,7 +35,9 @@ Timer::Timer(const ticker_data_t *data) : _running(), _start(), _time(), _ticker
Timer::~Timer() {
core_util_critical_section_enter();
if (_running) {
sleep_manager_unlock_deep_sleep();
if(_lock_deepsleep) {
sleep_manager_unlock_deep_sleep();
}
}
_running = 0;
core_util_critical_section_exit();