summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/StopWatch.cpp
diff options
context:
space:
mode:
authorMartin Ashby <martin@ashbysoft.com>2021-05-02 22:12:09 +0100
committerMartin Ashby <martin@ashbysoft.com>2021-05-03 08:11:58 +0100
commit3a938236d48430cb77660f15d712f7bc129d9539 (patch)
treecbdbe60355e2154e9d92b4d2dc3a62b958053fb2 /src/displayapp/screens/StopWatch.cpp
parente3ead332b9db3ad7b6acde933b6a7943b3ac81e2 (diff)
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
Diffstat (limited to 'src/displayapp/screens/StopWatch.cpp')
-rw-r--r--src/displayapp/screens/StopWatch.cpp3
1 files changed, 2 insertions, 1 deletions
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");