fix(refr): avoid division by zero (#7205)

This commit is contained in:
Carlos Diaz
2024-11-04 02:41:32 -06:00
committed by GitHub
parent 0380014efb
commit 9b90655ffb
+5
View File
@@ -1166,6 +1166,11 @@ static uint32_t get_max_row(lv_display_t * disp, int32_t area_w, int32_t area_h)
uint32_t stride = lv_draw_buf_width_to_stride(area_w, cf); uint32_t stride = lv_draw_buf_width_to_stride(area_w, cf);
uint32_t overhead = LV_COLOR_INDEXED_PALETTE_SIZE(cf) * sizeof(lv_color32_t); uint32_t overhead = LV_COLOR_INDEXED_PALETTE_SIZE(cf) * sizeof(lv_color32_t);
if(stride == 0) {
LV_LOG_WARN("Invalid stride. Value is 0");
return 0;
}
int32_t max_row = (uint32_t)(disp->buf_act->data_size - overhead) / stride; int32_t max_row = (uint32_t)(disp->buf_act->data_size - overhead) / stride;
if(max_row > area_h) max_row = area_h; if(max_row > area_h) max_row = area_h;