1
0
Fork 0

Fix a possible double free in StopWatch::Refresh.

The lv_obj_del is called on btnStopLap  when transitioning to the
initial state, however the variable isn't then set to null. A subsequent
call to Refresh would attempt to delete the already freed object. This
could be triggered by stopping the stop watch, then pressing the
physical button on the watch.

Fixes https://github.com/JF002/InfiniTime/issues/315
This commit is contained in:
Martin Ashby 2021-05-02 22:12:09 +01:00
parent e3ead332b9
commit 3a938236d4
No known key found for this signature in database
GPG key ID: 7C2A95403085B982

View file

@ -115,8 +115,9 @@ bool StopWatch::Refresh() {
// Init state when an user first opens the app // Init state when an user first opens the app
// and when a stop/reset button is pressed // and when a stop/reset button is pressed
case States::Init: { case States::Init: {
if (btnStopLap) { if (btnStopLap != nullptr) {
lv_obj_del(btnStopLap); lv_obj_del(btnStopLap);
btnStopLap = nullptr;
} }
// The initial default value // The initial default value
lv_label_set_text(time, "00:00"); lv_label_set_text(time, "00:00");