Skip to content

Commit

Permalink
Fix overrun in oled_write_raw when not at (0, 0) (#13204)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcat authored Jun 16, 2021
1 parent 5c3991c commit 83ee795
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/oled/oled_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,9 @@ void oled_write_raw(const char *data, uint16_t size) {
uint16_t cursor_start_index = oled_cursor - &oled_buffer[0];
if ((size + cursor_start_index) > OLED_MATRIX_SIZE) size = OLED_MATRIX_SIZE - cursor_start_index;
for (uint16_t i = cursor_start_index; i < cursor_start_index + size; i++) {
if (oled_buffer[i] == data[i]) continue;
oled_buffer[i] = data[i];
uint8_t c = *data++;
if (oled_buffer[i] == c) continue;
oled_buffer[i] = c;
oled_dirty |= ((OLED_BLOCK_TYPE)1 << (i / OLED_BLOCK_SIZE));
}
}
Expand Down

0 comments on commit 83ee795

Please sign in to comment.