From 617fa3fbd223f5870b5bfe585f0a1addd7f04689 Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Wed, 14 Feb 2018 22:02:38 +0100 Subject: [PATCH] Fixed memory leak in countdown screen, causing a crash within 2 minutes --- src/display.cpp | 1 - src/screen/countdown.cpp | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/display.cpp b/src/display.cpp index c1d5aa7..3c27587 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -119,7 +119,6 @@ const char* FormatPercentage(uint8_t percentage) { char* value = new char[6]; - itoa(percentage, value, 10); uint8_t length = strlen(value); diff --git a/src/screen/countdown.cpp b/src/screen/countdown.cpp index 5e6ef18..b663005 100644 --- a/src/screen/countdown.cpp +++ b/src/screen/countdown.cpp @@ -14,7 +14,9 @@ inline uint32_t intDivCeil(uint32_t x, uint32_t y) void CountdownScreen::printRemainingTime() { - LCDPrintLineCentered(getDisplay(), 1, FormatTime(mLastDisplayed)); + const char* time = FormatTime(mLastDisplayed); + LCDPrintLineCentered(getDisplay(), 1, time); + delete[] time; }