From c6c7fccd96b7e2455d2992b1e6f8c0e1df012ded Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sun, 17 Jan 2021 01:08:40 +0100 Subject: backend/headless: create renderer after wlr_backend_init We were calling wlr_renderer_autocreate before wlr_backend_init, which caused a NULL dereference on wlr_backend.impl. --- backend/headless/backend.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'backend/headless') diff --git a/backend/headless/backend.c b/backend/headless/backend.c index 02e3774a..ba5fde80 100644 --- a/backend/headless/backend.c +++ b/backend/headless/backend.c @@ -120,6 +120,14 @@ static bool backend_init(struct wlr_headless_backend *backend, wl_list_init(&backend->input_devices); backend->allocator = allocator; + + if (renderer == NULL) { + renderer = wlr_renderer_autocreate(&backend->backend); + if (!renderer) { + wlr_log(WLR_ERROR, "Failed to create renderer"); + return false; + } + } backend->renderer = renderer; const struct wlr_drm_format_set *formats = @@ -219,21 +227,13 @@ struct wlr_backend *wlr_headless_backend_create(struct wl_display *display) { goto error_dup; } - struct wlr_renderer *renderer = wlr_renderer_autocreate(&backend->backend); - if (!renderer) { - wlr_log(WLR_ERROR, "Failed to create renderer"); - goto error_renderer; - } - - if (!backend_init(backend, display, &gbm_alloc->base, renderer)) { + if (!backend_init(backend, display, &gbm_alloc->base, NULL)) { goto error_init; } return &backend->backend; error_init: - wlr_renderer_destroy(renderer); -error_renderer: wlr_allocator_destroy(&gbm_alloc->base); error_dup: close(backend->drm_fd); -- cgit v1.2.3