Browse Source

lcd_print_pad: do not overflow len when truncating the string

Yuri D'Elia 2 years ago
parent
commit
709d07310a
1 changed files with 4 additions and 1 deletions
  1. 4 1
      Firmware/lcd.cpp

+ 4 - 1
Firmware/lcd.cpp

@@ -530,7 +530,10 @@ void lcd_print(const char* s)
 
 
 void lcd_print_pad(const char* s, uint8_t len)
 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);
     lcd_space(len);
 }
 }