Skip to content

Commit

Permalink
fix(buttonmatrix): fix 1-off error in `lv_buttonmatrix_get_button_tex…
Browse files Browse the repository at this point in the history
…t()`

lv_buttonmatrix_get_button_text() function has this code in it to avoid
attempting to use a user-provided btn_id value that will make the
`while(btn_i != btn_id)` loop proceed past the end of the array of buttons.
However, it has a 1-off error which does permit it to go 1 past the end
of the array.  This PR fixes that error.
  • Loading branch information
vwheeler63 committed Oct 30, 2024
1 parent be85ad7 commit b46791e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/widgets/buttonmatrix/lv_buttonmatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ const char * lv_buttonmatrix_get_button_text(const lv_obj_t * obj, uint32_t btn_
if(btn_id == LV_BUTTONMATRIX_BUTTON_NONE) return NULL;

lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj;
if(btn_id > btnm->btn_cnt) return NULL;
if(btn_id >= btnm->btn_cnt) return NULL;

uint32_t txt_i = 0;
uint32_t btn_i = 0;
Expand Down

0 comments on commit b46791e

Please sign in to comment.