fix string overflow
this fixes a string overflow. The "null" character did not fir into tempString, leading array-write-out-of-bounds.
This commit is contained in:
@@ -54,8 +54,8 @@ uint16_t mode_2DWeather(void) {
|
|||||||
|
|
||||||
// Serial.print(" temp ");
|
// Serial.print(" temp ");
|
||||||
|
|
||||||
char tempString[5] = "";
|
char tempString[6] = { '\0' }; // initialize string with zeros
|
||||||
sprintf(tempString, "%5.2f", currentTemp);
|
snprintf(tempString, 5, "%5.2f", currentTemp); // snprintf will prevent overflow
|
||||||
// Serial.println();
|
// Serial.println();
|
||||||
|
|
||||||
CRGB color = ColorFromPalette(SEGPALETTE, map((uint8_t)currentTemp, 0, 40, 0, 255), 255, LINEARBLEND);
|
CRGB color = ColorFromPalette(SEGPALETTE, map((uint8_t)currentTemp, 0, 40, 0, 255), 255, LINEARBLEND);
|
||||||
|
|||||||
Reference in New Issue
Block a user