From f9eb5df80eaabdc72b2f2aa0998b409a89c17f68 Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 13 Oct 2018 10:58:59 +0200 Subject: [PATCH] backend: fix use-after-free in wlr_backend_autocreate Found by clang static analyzer. --- backend/backend.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/backend.c b/backend/backend.c index 4b186767..c5dcdb48 100644 --- a/backend/backend.c +++ b/backend/backend.c @@ -217,16 +217,16 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display, backend, &multi->session, name, create_renderer_func); if (subbackend == NULL) { wlr_log(WLR_ERROR, "failed to start backend '%s'", name); - wlr_backend_destroy(backend); wlr_session_destroy(multi->session); + wlr_backend_destroy(backend); free(names); return NULL; } if (!wlr_multi_backend_add(backend, subbackend)) { wlr_log(WLR_ERROR, "failed to add backend '%s'", name); - wlr_backend_destroy(backend); wlr_session_destroy(multi->session); + wlr_backend_destroy(backend); free(names); return NULL; } @@ -272,8 +272,8 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display, multi->session); if (!libinput) { wlr_log(WLR_ERROR, "Failed to start libinput backend"); - wlr_backend_destroy(backend); wlr_session_destroy(multi->session); + wlr_backend_destroy(backend); return NULL; } wlr_multi_backend_add(backend, libinput); @@ -283,8 +283,8 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display, if (!primary_drm) { wlr_log(WLR_ERROR, "Failed to open any DRM device"); wlr_backend_destroy(libinput); - wlr_backend_destroy(backend); wlr_session_destroy(multi->session); + wlr_backend_destroy(backend); return NULL; }