mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +03:00
prevent max7456 screen_buffer from overflow (#8063)
prevent max7456 screen_buffer from overflow
This commit is contained in:
parent
b57fd7b53d
commit
a7968c754d
1 changed files with 6 additions and 4 deletions
|
@ -571,14 +571,16 @@ uint8_t* max7456GetScreenBuffer(void)
|
|||
|
||||
void max7456WriteChar(uint8_t x, uint8_t y, uint8_t c)
|
||||
{
|
||||
screenBuffer[y*CHARS_PER_LINE+x] = c;
|
||||
if (x < CHARS_PER_LINE && y < VIDEO_LINES_PAL) {
|
||||
screenBuffer[y * CHARS_PER_LINE + x] = c;
|
||||
}
|
||||
}
|
||||
|
||||
void max7456Write(uint8_t x, uint8_t y, const char *buff)
|
||||
{
|
||||
for (int i = 0; *(buff+i); i++) {
|
||||
if (x+i < CHARS_PER_LINE) {// Do not write over screen
|
||||
screenBuffer[y*CHARS_PER_LINE+x+i] = *(buff+i);
|
||||
if (y < VIDEO_LINES_PAL) {
|
||||
for (int i = 0; buff[i] && x + i < CHARS_PER_LINE; i++) {
|
||||
screenBuffer[y * CHARS_PER_LINE + x + i] = buff[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue