backend: fix use-after-free in wlr_backend_autocreate

Found by clang static analyzer.
This commit is contained in:
emersion 2018-10-13 10:58:59 +02:00
parent cff471ce3e
commit f9eb5df80e

View file

@ -217,16 +217,16 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
backend, &multi->session, name, create_renderer_func); backend, &multi->session, name, create_renderer_func);
if (subbackend == NULL) { if (subbackend == NULL) {
wlr_log(WLR_ERROR, "failed to start backend '%s'", name); wlr_log(WLR_ERROR, "failed to start backend '%s'", name);
wlr_backend_destroy(backend);
wlr_session_destroy(multi->session); wlr_session_destroy(multi->session);
wlr_backend_destroy(backend);
free(names); free(names);
return NULL; return NULL;
} }
if (!wlr_multi_backend_add(backend, subbackend)) { if (!wlr_multi_backend_add(backend, subbackend)) {
wlr_log(WLR_ERROR, "failed to add backend '%s'", name); wlr_log(WLR_ERROR, "failed to add backend '%s'", name);
wlr_backend_destroy(backend);
wlr_session_destroy(multi->session); wlr_session_destroy(multi->session);
wlr_backend_destroy(backend);
free(names); free(names);
return NULL; return NULL;
} }
@ -272,8 +272,8 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
multi->session); multi->session);
if (!libinput) { if (!libinput) {
wlr_log(WLR_ERROR, "Failed to start libinput backend"); wlr_log(WLR_ERROR, "Failed to start libinput backend");
wlr_backend_destroy(backend);
wlr_session_destroy(multi->session); wlr_session_destroy(multi->session);
wlr_backend_destroy(backend);
return NULL; return NULL;
} }
wlr_multi_backend_add(backend, libinput); wlr_multi_backend_add(backend, libinput);
@ -283,8 +283,8 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
if (!primary_drm) { if (!primary_drm) {
wlr_log(WLR_ERROR, "Failed to open any DRM device"); wlr_log(WLR_ERROR, "Failed to open any DRM device");
wlr_backend_destroy(libinput); wlr_backend_destroy(libinput);
wlr_backend_destroy(backend);
wlr_session_destroy(multi->session); wlr_session_destroy(multi->session);
wlr_backend_destroy(backend);
return NULL; return NULL;
} }