Closed rozsapeter96 closed 5 months ago
Hello @rozsapeter96, have you faced any real crash due to this uninitialized pointer or it's just a safety measure? Actually those pointers are never used unless specific types of events are enabled per object instance, and when enabling event method is called, it will initialize timers and pointer variables.
Hi @vortigont! Yes, my code crashed without setting those pointers to nullptr. I used buttons with click events and with debouncing enabled like this:
for (auto button : buttons) { button->enableEvent(ESPButton::event_t::click); button->enableEvent(ESPButton::event_t::press, false); button->enableEvent(ESPButton::event_t::release, false); button->setDebounce(true); }
I should check how timer structure initialization is done in the SDK. But agreed initializing pointers is a bulletproof safe. Thanks for your contribution and test case.
Thank you @vortigont!
Uninitialized pointer values for 'longPressTimer_h' and 'multiclickTimer_h' could cause crashes.