From cab0fc793e2aa71539f3d50978d6a2b1b1f69259 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 8 Jan 2024 11:46:40 +0100 Subject: [PATCH] wayland: fix segfault when all backends fail When all Wayland backends fail, vaGetDisplayWl() would still return a half-constructed display context, resulting in a sefault in va_DRM_GetDrmDriverName() later on when trying to access ctx->drm_state->fd. Instead, cleanup and return NULL. Signed-off-by: Simon Ser --- va/wayland/va_wayland.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/va/wayland/va_wayland.c b/va/wayland/va_wayland.c index b3e1f5c8a..95ac3c36b 100644 --- a/va/wayland/va_wayland.c +++ b/va/wayland/va_wayland.c @@ -133,12 +133,10 @@ vaGetDisplayWl(struct wl_display *display) for (i = 0; g_backends[i].create != NULL; i++) { if (g_backends[i].create(pDisplayContext)) - break; + return (VADisplay)pDisplayContext; g_backends[i].destroy(pDisplayContext); } - return (VADisplay)pDisplayContext; - error: va_DisplayContextDestroy(pDisplayContext); return NULL;