fix(obj): fix memory leak in error handling (#6330)

Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
This commit is contained in:
Neo Xu
2024-06-11 17:45:14 +08:00
committed by GitHub
parent 6927a10d7e
commit ef697694d2

View File

@@ -67,8 +67,11 @@ lv_obj_t * lv_obj_class_create_obj(const lv_obj_class_t * class_p, lv_obj_t * pa
} }
lv_obj_t ** screens = lv_realloc(disp->screens, sizeof(lv_obj_t *) * (disp->screen_cnt + 1)); lv_obj_t ** screens = lv_realloc(disp->screens, sizeof(lv_obj_t *) * (disp->screen_cnt + 1));
LV_ASSERT_NULL(screens); LV_ASSERT_MALLOC(screens);
if(screens == NULL) return NULL; if(screens == NULL) {
lv_free(obj);
return NULL;
}
disp->screen_cnt++; disp->screen_cnt++;
disp->screens = screens; disp->screens = screens;