Merge pull request #858 from alfalfasprossen/ledcontrol/guard-against-nullptr-access

Guard against nullptr access in LEDControl
pull/859/head
Jesse Vincent 5 years ago committed by GitHub
commit c1a54a6bc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -28,7 +28,7 @@ static constexpr uint8_t uninitialized_mode_id = 255;
uint8_t LEDControl::mode_id = uninitialized_mode_id; uint8_t LEDControl::mode_id = uninitialized_mode_id;
uint8_t LEDControl::num_led_modes_ = LEDModeManager::numLEDModes(); uint8_t LEDControl::num_led_modes_ = LEDModeManager::numLEDModes();
LEDMode *LEDControl::cur_led_mode_; LEDMode *LEDControl::cur_led_mode_ = nullptr;
uint8_t LEDControl::syncDelay = 32; uint8_t LEDControl::syncDelay = 32;
uint16_t LEDControl::syncTimer = 0; uint16_t LEDControl::syncTimer = 0;
bool LEDControl::enabled_ = true; bool LEDControl::enabled_ = true;

@ -41,12 +41,14 @@ class LEDControl : public kaleidoscope::Plugin {
if (!Runtime.has_leds) if (!Runtime.has_leds)
return; return;
if (cur_led_mode_ != nullptr)
cur_led_mode_->update(); cur_led_mode_->update();
} }
static void refreshAt(KeyAddr key_addr) { static void refreshAt(KeyAddr key_addr) {
if (!Runtime.has_leds) if (!Runtime.has_leds)
return; return;
if (cur_led_mode_ != nullptr)
cur_led_mode_->refreshAt(key_addr); cur_led_mode_->refreshAt(key_addr);
} }
static void set_mode(uint8_t mode_id); static void set_mode(uint8_t mode_id);
@ -71,6 +73,7 @@ class LEDControl : public kaleidoscope::Plugin {
set_all_leds_to({0, 0, 0}); set_all_leds_to({0, 0, 0});
if (cur_led_mode_ != nullptr)
cur_led_mode_->onActivate(); cur_led_mode_->onActivate();
} }

Loading…
Cancel
Save