Skip to content

Commit

Permalink
fix(lv_refr): Avoid division by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
C47D committed Nov 1, 2024
1 parent a4f6660 commit 0bb24d7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/lv_refr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 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;

if(max_row > area_h) max_row = area_h;
Expand Down

0 comments on commit 0bb24d7

Please sign in to comment.