From c5e4d65e714ab4246d75c72903d1720fda730d93 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Sun, 8 Jan 2023 12:34:21 -0600 Subject: [PATCH] vo_wlshm: cleanup on failure If failure occurs during preinit, vo_wlshm should goto an error and cleaup itself like the other VOs. --- video/out/vo_wlshm.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/video/out/vo_wlshm.c b/video/out/vo_wlshm.c index fc9fc705fc..e3e6f647a0 100644 --- a/video/out/vo_wlshm.c +++ b/video/out/vo_wlshm.c @@ -128,22 +128,38 @@ error0: return NULL; } +static void uninit(struct vo *vo) +{ + struct priv *p = vo->priv; + struct buffer *buf; + + while (p->free_buffers) { + buf = p->free_buffers; + p->free_buffers = buf->next; + talloc_free(buf); + } + vo_wayland_uninit(vo); +} + static int preinit(struct vo *vo) { struct priv *p = vo->priv; if (!vo_wayland_init(vo)) - return -1; + goto err; if (!vo->wl->shm) { MP_FATAL(vo->wl, "Compositor doesn't support the %s protocol!\n", wl_shm_interface.name); - return -1; + goto err; } p->sws = mp_sws_alloc(vo); p->sws->log = vo->log; mp_sws_enable_cmdline_opts(p->sws, vo->global); return 0; +err: + uninit(vo); + return -1; } static int query_format(struct vo *vo, int format) @@ -278,19 +294,6 @@ static void get_vsync(struct vo *vo, struct vo_vsync_info *info) present_sync_get_info(wl->present, info); } -static void uninit(struct vo *vo) -{ - struct priv *p = vo->priv; - struct buffer *buf; - - while (p->free_buffers) { - buf = p->free_buffers; - p->free_buffers = buf->next; - talloc_free(buf); - } - vo_wayland_uninit(vo); -} - const struct vo_driver video_out_wlshm = { .description = "Wayland SHM video output (software scaling)", .name = "wlshm",