From cd6b4db6e8239ef2711e8c43a954650dc13a9a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E6=85=A7=E8=B5=9F?= <42379289+cnjhb@users.noreply.github.com> Date: Sat, 18 Nov 2023 08:08:54 +0000 Subject: [PATCH] chore(timer): add assertions for null pointer (#4823) --- src/misc/lv_timer.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/misc/lv_timer.c b/src/misc/lv_timer.c index 1af2785e5..7b7ec2f86 100644 --- a/src/misc/lv_timer.c +++ b/src/misc/lv_timer.c @@ -183,6 +183,7 @@ lv_timer_t * lv_timer_create(lv_timer_cb_t timer_xcb, uint32_t period, void * us void lv_timer_set_cb(lv_timer_t * timer, lv_timer_cb_t timer_cb) { + LV_ASSERT_NULL(timer); timer->timer_cb = timer_cb; } @@ -196,42 +197,50 @@ void lv_timer_delete(lv_timer_t * timer) void lv_timer_pause(lv_timer_t * timer) { + LV_ASSERT_NULL(timer); timer->paused = true; } void lv_timer_resume(lv_timer_t * timer) { + LV_ASSERT_NULL(timer); timer->paused = false; lv_timer_handler_resume(); } void lv_timer_set_period(lv_timer_t * timer, uint32_t period) { + LV_ASSERT_NULL(timer); timer->period = period; } void lv_timer_ready(lv_timer_t * timer) { + LV_ASSERT_NULL(timer); timer->last_run = lv_tick_get() - timer->period - 1; } void lv_timer_set_repeat_count(lv_timer_t * timer, int32_t repeat_count) { + LV_ASSERT_NULL(timer); timer->repeat_count = repeat_count; } void lv_timer_set_auto_delete(lv_timer_t * timer, bool auto_delete) { + LV_ASSERT_NULL(timer); timer->auto_delete = auto_delete; } void lv_timer_set_user_data(lv_timer_t * timer, void * user_data) { + LV_ASSERT_NULL(timer); timer->user_data = user_data; } void lv_timer_reset(lv_timer_t * timer) { + LV_ASSERT_NULL(timer); timer->last_run = lv_tick_get(); lv_timer_handler_resume(); }