display & fb_pool: Clean up memory leaks

fb-api-v3
Andri Yngvason 2021-09-04 20:46:48 +00:00
parent 77d8efcbe3
commit 2095913688
2 changed files with 6 additions and 2 deletions

View File

@ -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) 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); nvnc_fb_unref(self->buffer);
}
free(self); free(self);
} }

View File

@ -65,6 +65,7 @@ static void nvnc_fb_pool__destroy_fbs(struct nvnc_fb_pool* self)
struct fbq_item* item = TAILQ_FIRST(&self->fbs); struct fbq_item* item = TAILQ_FIRST(&self->fbs);
TAILQ_REMOVE(&self->fbs, item, link); TAILQ_REMOVE(&self->fbs, item, link);
nvnc_fb_unref(item->fb); 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 || if (fb->width != self->width || fb->height != self->height ||
fb->fourcc_format != self->fourcc_format) { fb->fourcc_format != self->fourcc_format) {
nvnc_fb_unref(fb);
return; return;
} }
nvnc_fb_ref(fb);
struct fbq_item* item = calloc(1, sizeof(*item)); struct fbq_item* item = calloc(1, sizeof(*item));
assert(item); assert(item);