feat(obj): add check null pointer (#6249)

Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
This commit is contained in:
Neo Xu
2024-05-27 00:01:07 +08:00
committed by GitHub
parent 01749e0687
commit 64598041be
2 changed files with 7 additions and 1 deletions

View File

@@ -98,6 +98,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent)
{
LV_LOG_INFO("begin");
lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent);
LV_ASSERT_NULL(obj);
if(obj == NULL) return NULL;
lv_obj_class_init_obj(obj);
return obj;
}

View File

@@ -66,8 +66,12 @@ lv_obj_t * lv_obj_class_create_obj(const lv_obj_class_t * class_p, lv_obj_t * pa
disp->screen_cnt = 0;
}
lv_obj_t ** screens = lv_realloc(disp->screens, sizeof(lv_obj_t *) * (disp->screen_cnt + 1));
LV_ASSERT_NULL(screens);
if(screens == NULL) return NULL;
disp->screen_cnt++;
disp->screens = lv_realloc(disp->screens, sizeof(lv_obj_t *) * disp->screen_cnt);
disp->screens = screens;
disp->screens[disp->screen_cnt - 1] = obj;
/*Set coordinates to full screen size*/