Explorar o código

Fix PROGMEM read in ProgressCode message

This could cause the printer to crash. The Serial Stream would show
a garbled string and the same corruption would appear on the Status
Screen's status line.
Guðni Már Gilbert %!s(int64=3) %!d(string=hai) anos
pai
achega
4b71466526
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      Firmware/mmu2_progress_converter.cpp

+ 2 - 1
Firmware/mmu2_progress_converter.cpp

@@ -62,7 +62,8 @@ static const char * const progressTexts[] PROGMEM = {
 };
 
 const char * const ProgressCodeToText(uint16_t pc){
-    return ( pc <= 26 ) ? progressTexts[pc] : progressTexts[0]; // @@TODO ?? a better fallback option?
+    // @@TODO ?? a better fallback option?
+    return ( pc <= 26 ) ? static_cast<const char * const>(pgm_read_ptr(&progressTexts[pc])) : static_cast<const char * const>(pgm_read_ptr(&progressTexts[0]));
 }
 
 void TranslateProgress(uint16_t pc, char *dst, size_t dstSize) {