Commit 8b5fb492 authored by russhughes's avatar russhughes

fixed uint16_t overflows, replaced with size_t

parent dc0a669c
...@@ -659,7 +659,7 @@ STATIC mp_obj_t st7789_ST7789_write(size_t n_args, const mp_obj_t *args) ...@@ -659,7 +659,7 @@ STATIC mp_obj_t st7789_ST7789_write(size_t n_args, const mp_obj_t *args)
// allocate buffer large enough the the widest character in the font // allocate buffer large enough the the widest character in the font
// if a buffer was not specified during the driver init. // if a buffer was not specified during the driver init.
uint32_t buf_size = max_width * height * 2; size_t buf_size = max_width * height * 2;
if (self->buffer_size == 0) { if (self->buffer_size == 0) {
self->i2c_buffer = m_malloc(buf_size); self->i2c_buffer = m_malloc(buf_size);
} }
...@@ -792,12 +792,12 @@ STATIC mp_obj_t st7789_ST7789_bitmap(size_t n_args, const mp_obj_t *args) ...@@ -792,12 +792,12 @@ STATIC mp_obj_t st7789_ST7789_bitmap(size_t n_args, const mp_obj_t *args)
mp_get_buffer_raise(bitmap_data_buff, &bufinfo, MP_BUFFER_READ); mp_get_buffer_raise(bitmap_data_buff, &bufinfo, MP_BUFFER_READ);
bitmap_data = bufinfo.buf; bitmap_data = bufinfo.buf;
uint16_t buf_size = width * height * 2; size_t buf_size = width * height * 2;
if (self->buffer_size == 0) { if (self->buffer_size == 0) {
self->i2c_buffer = m_malloc(buf_size); self->i2c_buffer = m_malloc(buf_size);
} }
uint32_t ofs = 0; size_t ofs = 0;
bs_bit = 0; bs_bit = 0;
if (bitmaps) { if (bitmaps) {
if (idx < bitmaps) { if (idx < bitmaps) {
...@@ -874,7 +874,7 @@ STATIC mp_obj_t st7789_ST7789_text(size_t n_args, const mp_obj_t *args) ...@@ -874,7 +874,7 @@ STATIC mp_obj_t st7789_ST7789_text(size_t n_args, const mp_obj_t *args)
bg_color = _swap_bytes(BLACK); bg_color = _swap_bytes(BLACK);
uint8_t wide = width / 8; uint8_t wide = width / 8;
uint16_t buf_size = width * height * 2; size_t buf_size = width * height * 2;
if (self->buffer_size == 0) { if (self->buffer_size == 0) {
self->i2c_buffer = m_malloc(buf_size); self->i2c_buffer = m_malloc(buf_size);
......
...@@ -87,7 +87,7 @@ typedef struct _st7789_ST7789_obj_t { ...@@ -87,7 +87,7 @@ typedef struct _st7789_ST7789_obj_t {
mp_file_t *fp; // file object mp_file_t *fp; // file object
uint16_t *i2c_buffer; // resident buffer if buffer_size given uint16_t *i2c_buffer; // resident buffer if buffer_size given
void *work; // work buffer for jpg decoding void *work; // work buffer for jpg decoding
uint16_t buffer_size; // resident buffer size, 0=dynamic size_t buffer_size; // resident buffer size, 0=dynamic
uint16_t display_width; // physical width uint16_t display_width; // physical width
uint16_t width; // logical width (after rotation) uint16_t width; // logical width (after rotation)
uint16_t display_height; // physical width uint16_t display_height; // physical width
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment