fix(lv_canvas): fix undefined behavior (#5059)

```bash
Left shift of 255 by 24 places cannot be represented in type 'int'
  at 0x102d47f44 lv_canvas_fill_bg (lv_canvas.c:310)
  at 0x102812b30 canvas_basic_render(unsigned char*, unsigned char, char const*, char const*) (main.cpp:38)
  at 0x102811fd4 canvas_blend_test(_lv_obj_t*, _lv_draw_image_dsc_t*, char const*, char const*, unsigned char, unsigned int) (main.cpp:108)
  at 0x102814f50 canvas_draw(char const*, unsigned char) (main.cpp:154)
  at 0x102814858 test_xrgb8888() (main.cpp:162)
  at 0x10281536c main (main.cpp:218)
  at 0x18d0790dc
```
This commit is contained in:
Benign X
2023-12-20 14:17:19 +08:00
committed by GitHub
parent ac3c623abd
commit ccc63521d0

View File

@@ -311,7 +311,7 @@ void lv_canvas_fill_bg(lv_obj_t * obj, lv_color_t color, lv_opa_t opa)
uint32_t c32 = lv_color_to_u32(color); uint32_t c32 = lv_color_to_u32(color);
if(header->cf == LV_COLOR_FORMAT_ARGB8888) { if(header->cf == LV_COLOR_FORMAT_ARGB8888) {
c32 &= 0x00ffffff; c32 &= 0x00ffffff;
c32 |= opa << 24; c32 |= (uint32_t)opa << 24;
} }
for(y = 0; y < header->h; y++) { for(y = 0; y < header->h; y++) {
uint32_t * buf32 = (uint32_t *)(data + y * stride); uint32_t * buf32 = (uint32_t *)(data + y * stride);