From aa721cafd9d5ce077ba7af35e299ad9cc56294cc Mon Sep 17 00:00:00 2001
From: Yuri D'Elia <wavexx@thregr.org>
Date: Mon, 26 Sep 2022 11:26:10 +0200
Subject: [PATCH] lcd_print_pad: do not overflow len when truncating the string

---
 Firmware/lcd.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Firmware/lcd.cpp b/Firmware/lcd.cpp
index 0c465273..2ba71a72 100644
--- a/Firmware/lcd.cpp
+++ b/Firmware/lcd.cpp
@@ -530,7 +530,10 @@ void lcd_print(const char* s)
 
 void lcd_print_pad(const char* s, uint8_t len)
 {
-    while (len-- && *s) lcd_write(*(s++));
+    while (len && *s) {
+        lcd_write(*(s++));
+        --len;
+    }
     lcd_space(len);
 }