From 20959136887e6a7297798d9f3b3fbc9dbe0fbf17 Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Sat, 4 Sep 2021 20:46:48 +0000 Subject: [PATCH] display & fb_pool: Clean up memory leaks --- src/display.c | 4 +++- src/fb_pool.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/display.c b/src/display.c index 3bda45f..f862c53 100644 --- a/src/display.c +++ b/src/display.c @@ -40,8 +40,10 @@ struct nvnc_display* nvnc_display_new(uint16_t x_pos, uint16_t y_pos) static void nvnc__display_free(struct nvnc_display* self) { - if (self->buffer) + if (self->buffer) { + nvnc_fb_release(self->buffer); nvnc_fb_unref(self->buffer); + } free(self); } diff --git a/src/fb_pool.c b/src/fb_pool.c index fe7846d..4dbd630 100644 --- a/src/fb_pool.c +++ b/src/fb_pool.c @@ -65,6 +65,7 @@ static void nvnc_fb_pool__destroy_fbs(struct nvnc_fb_pool* self) struct fbq_item* item = TAILQ_FIRST(&self->fbs); TAILQ_REMOVE(&self->fbs, item, link); nvnc_fb_unref(item->fb); + free(item); } } @@ -152,9 +153,10 @@ void nvnc_fb_pool_release(struct nvnc_fb_pool* self, struct nvnc_fb* fb) { if (fb->width != self->width || fb->height != self->height || fb->fourcc_format != self->fourcc_format) { - nvnc_fb_unref(fb); return; } + + nvnc_fb_ref(fb); struct fbq_item* item = calloc(1, sizeof(*item)); assert(item);