Merge pull request #101 from chenghongyao/fix_data_length_overflow

ST7789: Fix data length overflow on `send_color` by changing the length parameter from uint16_t to size_t
This commit is contained in:
Carlos Diaz 2021-08-17 15:36:41 -05:00 committed by GitHub
commit 82583ce6ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -35,7 +35,7 @@ typedef struct {
**********************/ **********************/
static void st7789_set_orientation(uint8_t orientation); static void st7789_set_orientation(uint8_t orientation);
static void st7789_send_color(void *data, uint16_t length); static void st7789_send_color(void *data, size_t length);
/********************** /**********************
* STATIC VARIABLES * STATIC VARIABLES
@ -167,7 +167,7 @@ void st7789_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
/*Memory write*/ /*Memory write*/
st7789_send_cmd(ST7789_RAMWR); st7789_send_cmd(ST7789_RAMWR);
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area); size_t size = (size_t)lv_area_get_width(area) * (size_t)lv_area_get_height(area);
st7789_send_color((void*)color_map, size * 2); st7789_send_color((void*)color_map, size * 2);
@ -190,7 +190,7 @@ void st7789_send_data(void * data, uint16_t length)
disp_spi_send_data(data, length); disp_spi_send_data(data, length);
} }
static void st7789_send_color(void * data, uint16_t length) static void st7789_send_color(void * data, size_t length)
{ {
disp_wait_for_pending_transactions(); disp_wait_for_pending_transactions();
gpio_set_level(ST7789_DC, 1); gpio_set_level(ST7789_DC, 1);