From 3a938236d48430cb77660f15d712f7bc129d9539 Mon Sep 17 00:00:00 2001 From: Martin Ashby Date: Sun, 2 May 2021 22:12:09 +0100 Subject: [PATCH] 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 --- src/displayapp/screens/StopWatch.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp index e06981af..d7cd20c3 100644 --- a/src/displayapp/screens/StopWatch.cpp +++ b/src/displayapp/screens/StopWatch.cpp @@ -115,8 +115,9 @@ bool StopWatch::Refresh() { // Init state when an user first opens the app // and when a stop/reset button is pressed case States::Init: { - if (btnStopLap) { + if (btnStopLap != nullptr) { lv_obj_del(btnStopLap); + btnStopLap = nullptr; } // The initial default value lv_label_set_text(time, "00:00");