1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

fix(style) check style count overflow (#3627)

This commit is contained in:
Bora Özgen 2022-08-26 17:34:46 +02:00 committed by GitHub
parent 314a1d79a8
commit 89e3a712cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -89,6 +89,7 @@ void lv_obj_add_style(lv_obj_t * obj, const lv_style_t * style, lv_style_selecto
/*Allocate space for the new style and shift the rest of the style to the end*/
obj->style_cnt++;
LV_ASSERT(obj->style_cnt != 0);
obj->styles = lv_realloc(obj->styles, obj->style_cnt * sizeof(_lv_obj_style_t));
LV_ASSERT_MALLOC(obj->styles);
@ -519,6 +520,7 @@ static lv_style_t * get_local_style(lv_obj_t * obj, lv_style_selector_t selector
}
obj->style_cnt++;
LV_ASSERT(obj->style_cnt != 0);
obj->styles = lv_realloc(obj->styles, obj->style_cnt * sizeof(_lv_obj_style_t));
LV_ASSERT_MALLOC(obj->styles);
@ -556,6 +558,7 @@ static _lv_obj_style_t * get_trans_style(lv_obj_t * obj, lv_style_selector_t se
if(i != obj->style_cnt) return &obj->styles[i];
obj->style_cnt++;
LV_ASSERT(obj->style_cnt != 0);
obj->styles = lv_realloc(obj->styles, obj->style_cnt * sizeof(_lv_obj_style_t));
for(i = obj->style_cnt - 1; i > 0 ; i--) {