From 314c02194a19016d83fb71a41f6f647959b7be1e Mon Sep 17 00:00:00 2001 From: Reinhold Gschweicher Date: Sun, 23 Jan 2022 23:34:25 +0100 Subject: [PATCH] Music: initialize totalLength to have non-random data from the start In the first `Music::Refresh` call the lastLength and totalLength are not initialized. The `lastLength` value is read first from the musicService. Naturally in the first itereation that is changed and `UpdateLength()` is called. There the variable `totalLength` is used as well, but that variable isn't initialed to a sensible value yet. This leads to sometimes the `Music.h` screen segfaulting (depending on the random uninitialized data in the `lastLength` variable) --- src/displayapp/screens/Music.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/displayapp/screens/Music.h b/src/displayapp/screens/Music.h index f9b4eaab..35f7bab5 100644 --- a/src/displayapp/screens/Music.h +++ b/src/displayapp/screens/Music.h @@ -69,7 +69,7 @@ namespace Pinetime { std::string track; /** Total length in seconds */ - int totalLength; + int totalLength = 0; /** Current length in seconds */ int currentLength; /** Last length */