Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: strengthen lcd buffer protection #4550

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion radio/src/gui/128x64/lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ void lcdMaskPoint(uint8_t * p, uint8_t mask, LcdFlags att)
void lcdDrawPoint(coord_t x, coord_t y, LcdFlags att)
{
uint8_t * p = &displayBuf[ y / 8 * LCD_W + x ];
if (p < DISPLAY_END) {
if (IS_IN_DISPLAY(p)) {
lcdMaskPoint(p, bfBit<uint8_t>(y % 8), att);
}
}
Expand Down
1 change: 1 addition & 0 deletions radio/src/gui/128x64/lcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ extern coord_t lcdLastLeftPos;
extern coord_t lcdNextPos;

#define DISPLAY_END (displayBuf + DISPLAY_BUFFER_SIZE)
#define IS_IN_DISPLAY(p) ((p) >= displayBuf && (p) < DISPLAY_END)
#define ASSERT_IN_DISPLAY(p) assert((p) >= displayBuf && (p) < DISPLAY_END)


Expand Down
2 changes: 2 additions & 0 deletions radio/src/gui/common/stdlcd/model_curves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ void drawFunction(FnFuncP fn, uint8_t offset)

for (int xv = -CURVE_SIDE_WIDTH; xv <= CURVE_SIDE_WIDTH; xv++) {
coord_t yv = -(fn((xv * RESX) / CURVE_SIDE_WIDTH) * (CURVE_SIDE_WIDTH*2+1) / (RESX*2));
if (yv < -CURVE_SIDE_WIDTH) yv = -CURVE_SIDE_WIDTH;
if (yv > CURVE_SIDE_WIDTH) yv = CURVE_SIDE_WIDTH;
if ((xv > -CURVE_SIDE_WIDTH) && (abs((int8_t)yv-prev_yv) > 1)) {
int len = 0;
if (yv > prev_yv) {
Expand Down