backend/drm: Ensure renderer is set to NULL on error

If init_drm_renderer failed, it would destroy the renderer but would not
set it to NULL, leading to use-after-free.

NULL the renderer after destroying it.
This commit is contained in:
Kenny Levinsen 2024-11-07 23:10:39 +01:00
parent 70d3635985
commit 55f15d1abd

View File

@ -25,6 +25,7 @@ bool init_drm_renderer(struct wlr_drm_backend *drm,
if (renderer->allocator == NULL) { if (renderer->allocator == NULL) {
wlr_log(WLR_ERROR, "Failed to create allocator"); wlr_log(WLR_ERROR, "Failed to create allocator");
wlr_renderer_destroy(renderer->wlr_rend); wlr_renderer_destroy(renderer->wlr_rend);
renderer->wlr_rend = NULL;
return false; return false;
} }