games: fix string overflow / stack corruption

warning: '%1d' directive writing between 1 and 3 bytes into a region of size 2
This commit is contained in:
Frank
2022-11-24 17:08:58 +01:00
parent dfd839de87
commit 484e995295

View File

@@ -164,8 +164,8 @@ uint16_t mode_pongGame(void) {
SEGMENT.setPixelColorXY(vW/2, i, BLUE);
}
char tempString[2] = "";
sprintf(tempString, "%1d%1d", ball->scoreRight, ball->scoreLeft);
char tempString[4] = { '\0' };
snprintf(tempString, 4, "%1d%1d", ball->scoreRight, ball->scoreLeft);
SEGMENT.drawCharacter(tempString[0], vW/2-5, -2, 5, 8, BLUE);
SEGMENT.drawCharacter(tempString[1], vW/2+2, -2, 5, 8, BLUE);