Skip to content

Commit 3cff638

Browse files
committed
Clean up various memory leaks
1 parent 3cd4e7f commit 3cff638

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

src/buffer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ void wv_buffer_pool_reconfig(struct wv_buffer_pool* pool,
538538
if (old_node != config->node) {
539539
if (pool->gbm)
540540
gbm_device_destroy(pool->gbm);
541+
pool->gbm = NULL;
541542
if (pool->gbm_fd > 0)
542543
close(pool->gbm_fd);
543544
pool->gbm_fd = -1;

src/ext-image-copy-capture.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ static void ext_image_copy_capture_deinit_session(struct ext_image_copy_capture*
9595
if (self->cursor)
9696
ext_image_copy_capture_cursor_session_v1_destroy(self->cursor);
9797
self->cursor = NULL;
98+
99+
if (self->buffer)
100+
wv_buffer_pool_release(self->pool, self->buffer);
101+
self->buffer = NULL;
98102
}
99103

100104
static int ext_image_copy_capture_init_session(struct ext_image_copy_capture* self)
@@ -591,14 +595,8 @@ void ext_image_copy_capture_destroy(struct screencopy* ptr)
591595
aml_stop(aml_get_default(), self->timer);
592596
aml_unref(self->timer);
593597

594-
if (self->frame)
595-
ext_image_copy_capture_frame_v1_destroy(self->frame);
596-
if (self->cursor)
597-
ext_image_copy_capture_cursor_session_v1_destroy(self->cursor);
598-
if (self->session)
599-
ext_image_copy_capture_session_v1_destroy(self->session);
600-
if (self->buffer)
601-
wv_buffer_pool_release(self->pool, self->buffer);
598+
ext_image_copy_capture_deinit_session(self);
599+
602600
wv_buffer_pool_destroy(self->pool);
603601
free(self);
604602
}

src/main.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,16 +418,13 @@ static void wayland_detach(struct wayvnc* self)
418418
zwp_linux_dmabuf_v1_destroy(zwp_linux_dmabuf);
419419
zwp_linux_dmabuf = NULL;
420420

421-
if (screencopy_manager) {
422-
screencopy_stop(self->screencopy);
423-
screencopy_destroy(self->screencopy);
424-
self->screencopy = NULL;
425-
screencopy_stop(self->cursor_sc);
426-
screencopy_destroy(self->cursor_sc);
427-
self->cursor_sc = NULL;
428-
zwlr_screencopy_manager_v1_destroy(screencopy_manager);
429-
}
430-
screencopy_manager = NULL;
421+
screencopy_stop(self->screencopy);
422+
screencopy_destroy(self->screencopy);
423+
self->screencopy = NULL;
424+
425+
screencopy_stop(self->cursor_sc);
426+
screencopy_destroy(self->cursor_sc);
427+
self->cursor_sc = NULL;
431428

432429
if (xdg_output_manager)
433430
zxdg_output_manager_v1_destroy(xdg_output_manager);
@@ -477,6 +474,9 @@ static void wayland_detach(struct wayvnc* self)
477474
aml_unref(self->capture_retry_timer);
478475
self->capture_retry_timer = NULL;
479476

477+
if (self->transient_seat_manager)
478+
ext_transient_seat_manager_v1_destroy(self->transient_seat_manager);
479+
480480
wl_registry_destroy(self->registry);
481481
self->registry = NULL;
482482

src/screencopy.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ static void wlr_screencopy_destroy(struct screencopy* ptr)
356356
self->front = NULL;
357357

358358
wv_buffer_pool_destroy(self->pool);
359+
free(self);
359360
}
360361

361362
struct screencopy_impl wlr_screencopy_impl = {

0 commit comments

Comments
 (0)