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

-fix using freed memory in _lv_style_list_remove_style

Fixes: #1694
This commit is contained in:
Gabor Kiss-Vamosi 2020-08-02 12:04:10 +02:00
parent 2b60f4496f
commit 28213adfa6
2 changed files with 4 additions and 2 deletions

View File

@ -257,7 +257,7 @@ void _lv_style_list_remove_style(lv_style_list_t * list, lv_style_t * style)
return;
}
lv_style_t ** new_classes = lv_mem_realloc(list->style_list, sizeof(lv_style_t *) * (list->style_cnt - 1));
lv_style_t ** new_classes = lv_mem_alloc(sizeof(lv_style_t *) * (list->style_cnt - 1));
LV_ASSERT_MEM(new_classes);
if(new_classes == NULL) {
LV_LOG_WARN("lv_style_list_remove_style: couldn't reallocate class list");
@ -271,6 +271,8 @@ void _lv_style_list_remove_style(lv_style_list_t * list, lv_style_t * style)
}
lv_mem_free(list->style_list);
list->style_cnt--;
list->style_list = new_classes;
}

View File

@ -570,7 +570,7 @@ bool lv_debug_check_style_list(const lv_style_list_t * list);
* lv_style_init(&my_style);
* lv_style_copy(&my_style, &style_to_copy);
*/
#define LV_STYLE_CREATE(name, copy_p) static lv_style_t name; lv_style_init(&name); lv_style_copy(&name, copy);
#define LV_STYLE_CREATE(name, copy_p) static lv_style_t name; lv_style_init(&name); lv_style_copy(&name, copy_p);