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/5268/head
Russ Butler 2017-10-02 19:32:20 -05:00 committed by adbridge
parent 95b6acd095
commit 8a683a4ccc
1 changed files with 3 additions and 1 deletions

View File

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