feat(obj): add check null pointer (#6249)
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
This commit is contained in:
@@ -98,6 +98,8 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent)
|
|||||||
{
|
{
|
||||||
LV_LOG_INFO("begin");
|
LV_LOG_INFO("begin");
|
||||||
lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent);
|
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);
|
lv_obj_class_init_obj(obj);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
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->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;
|
disp->screens[disp->screen_cnt - 1] = obj;
|
||||||
|
|
||||||
/*Set coordinates to full screen size*/
|
/*Set coordinates to full screen size*/
|
||||||
|
|||||||
Reference in New Issue
Block a user