mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
fix(chart): fix memory leak (#6727)
Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com> Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
parent
e28caac406
commit
4349dfc593
@ -293,6 +293,7 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * obj, lv_color_t color, lv_cha
|
||||
lv_chart_series_t * ser = lv_ll_ins_tail(&chart->series_ll);
|
||||
LV_ASSERT_MALLOC(ser);
|
||||
if(ser == NULL) return NULL;
|
||||
lv_memzero(ser, sizeof(lv_chart_series_t));
|
||||
|
||||
/* Allocate memory for point_cnt points, handle failure below */
|
||||
ser->y_points = lv_malloc(sizeof(int32_t) * chart->point_cnt);
|
||||
@ -313,6 +314,11 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * obj, lv_color_t color, lv_cha
|
||||
}
|
||||
|
||||
if(ser->y_points == NULL) {
|
||||
if(ser->x_points) {
|
||||
lv_free(ser->x_points);
|
||||
ser->x_points = NULL;
|
||||
}
|
||||
|
||||
lv_ll_remove(&chart->series_ll, ser);
|
||||
lv_free(ser);
|
||||
return NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user