fix(battery): Safety check

Make sure returned label is valid before access.

Refs #318
This commit is contained in:
Michael Carlberg 2017-01-11 15:01:38 +01:00
parent 30201bac38
commit d7d0fbcae4

View File

@ -198,11 +198,13 @@ namespace modules {
} }
}(); }();
label->reset_tokens(); if (label) {
label->replace_token("%percentage%", to_string(m_percentage) + "%"); label->reset_tokens();
label->replace_token("%percentage%", to_string(m_percentage) + "%");
if (m_state != battery_module::state::FULL && !m_timeformat.empty()) { if (m_state != battery_module::state::FULL && !m_timeformat.empty()) {
label->replace_token("%time%", current_time()); label->replace_token("%time%", current_time());
}
} }
return true; return true;