From 4e52b15508adaf5b320bc8a2aaad1ff3a9043e64 Mon Sep 17 00:00:00 2001 From: Chishin Date: Fri, 10 Jan 2025 10:27:59 +0800 Subject: [PATCH] fix(sysmon): fix heap memory overflow (#7576) --- src/others/sysmon/lv_sysmon.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/others/sysmon/lv_sysmon.c b/src/others/sysmon/lv_sysmon.c index 46d7f50b4..16e8d6a3d 100644 --- a/src/others/sysmon/lv_sysmon.c +++ b/src/others/sysmon/lv_sysmon.c @@ -105,17 +105,19 @@ void lv_sysmon_show_performance(lv_display_t * disp) return; } - disp->perf_label = lv_sysmon_create(disp); if(disp->perf_label == NULL) { - LV_LOG_WARN("Couldn't create sysmon"); - return; - } + disp->perf_label = lv_sysmon_create(disp); + if(disp->perf_label == NULL) { + LV_LOG_WARN("Couldn't create sysmon"); + return; + } - lv_subject_init_pointer(&disp->perf_sysmon_backend.subject, &disp->perf_sysmon_info); - lv_obj_align(disp->perf_label, LV_USE_PERF_MONITOR_POS, 0, 0); - lv_subject_add_observer_obj(&disp->perf_sysmon_backend.subject, perf_observer_cb, disp->perf_label, NULL); - disp->perf_sysmon_backend.timer = lv_timer_create(perf_update_timer_cb, LV_SYSMON_REFR_PERIOD_DEF, disp); - lv_display_add_event_cb(disp, perf_monitor_disp_event_cb, LV_EVENT_ALL, NULL); + lv_subject_init_pointer(&disp->perf_sysmon_backend.subject, &disp->perf_sysmon_info); + lv_obj_align(disp->perf_label, LV_USE_PERF_MONITOR_POS, 0, 0); + lv_subject_add_observer_obj(&disp->perf_sysmon_backend.subject, perf_observer_cb, disp->perf_label, NULL); + disp->perf_sysmon_backend.timer = lv_timer_create(perf_update_timer_cb, LV_SYSMON_REFR_PERIOD_DEF, disp); + lv_display_add_event_cb(disp, perf_monitor_disp_event_cb, LV_EVENT_ALL, NULL); + } #if LV_USE_PERF_MONITOR_LOG_MODE lv_obj_add_flag(disp->perf_label, LV_OBJ_FLAG_HIDDEN); @@ -147,14 +149,16 @@ void lv_sysmon_show_memory(lv_display_t * disp) return; } - disp->mem_label = lv_sysmon_create(disp); if(disp->mem_label == NULL) { - LV_LOG_WARN("Couldn't create sysmon"); - return; - } + disp->mem_label = lv_sysmon_create(disp); + if(disp->mem_label == NULL) { + LV_LOG_WARN("Couldn't create sysmon"); + return; + } - lv_obj_align(disp->mem_label, LV_USE_MEM_MONITOR_POS, 0, 0); - lv_subject_add_observer_obj(&sysmon_mem.subject, mem_observer_cb, disp->mem_label, NULL); + lv_obj_align(disp->mem_label, LV_USE_MEM_MONITOR_POS, 0, 0); + lv_subject_add_observer_obj(&sysmon_mem.subject, mem_observer_cb, disp->mem_label, NULL); + } lv_obj_remove_flag(disp->mem_label, LV_OBJ_FLAG_HIDDEN); }