1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

fix(draw): solve memory leaking issue (#3437)

* fix(draw): solve memory leaking issue

* Update lv_draw_sw_layer.c

* Revert "Update lv_draw_sw_layer.c"

This reverts commit 4ca1ab303c1e0297529f7eb662ea4ee7f24b10fa.

* Revert "fix(draw): solve memory leaking issue"

This reverts commit 6f36e1a8c324abf79423b83bea9611f8cd59664d.

* fix(draw): free layer ctx when layer_init returns NULL

* Update lv_draw_layer.c
This commit is contained in:
Gabriel Wang 2022-07-01 13:27:05 +01:00 committed by GitHub
parent 25ce6e3ae9
commit a2bd96023f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -55,7 +55,11 @@ lv_draw_layer_ctx_t * lv_draw_layer_create(lv_draw_ctx_t * draw_ctx, const lv_ar
layer_ctx->original.screen_transp = disp_refr->driver->screen_transp;
layer_ctx->area_full = *layer_area;
return draw_ctx->layer_init(draw_ctx, layer_ctx, flags);
lv_draw_layer_ctx_t * init_layer_ctx = draw_ctx->layer_init(draw_ctx, layer_ctx, flags);
if(NULL == init_layer_ctx) {
lv_mem_free(layer_ctx);
}
return init_layer_ctx;
}
void lv_draw_layer_adjust(struct _lv_draw_ctx_t * draw_ctx, struct _lv_draw_layer_ctx_t * layer_ctx,

View File

@ -61,7 +61,6 @@ struct _lv_draw_layer_ctx_t * lv_draw_sw_layer_create(struct _lv_draw_ctx_t * dr
layer_sw_ctx->buf_size_bytes = LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE;
layer_sw_ctx->base_draw.buf = lv_mem_alloc(layer_sw_ctx->buf_size_bytes);
if(layer_sw_ctx->base_draw.buf == NULL) {
lv_mem_free(layer_ctx);
return NULL;
}
}
@ -78,7 +77,6 @@ struct _lv_draw_layer_ctx_t * lv_draw_sw_layer_create(struct _lv_draw_ctx_t * dr
lv_memset_00(layer_sw_ctx->base_draw.buf, layer_sw_ctx->buf_size_bytes);
layer_sw_ctx->has_alpha = flags & LV_DRAW_LAYER_FLAG_HAS_ALPHA ? 1 : 0;
if(layer_sw_ctx->base_draw.buf == NULL) {
lv_mem_free(layer_ctx);
return NULL;
}