From 5b357a4bbba0562063c6738f52995ea0823174f2 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Thu, 11 Mar 2021 11:05:16 +0200 Subject: [PATCH] backend-rdp: Correctly tear down the RDP back-end This fixes the tear-down and the destroying part in case RDP back-end couldn't be initialized. The first issue is the rdp_output which will not be created in some circumstances (can't open the socket for instance) and requires a guard check, and secondly, the rdp_head being created above of that, wasn't removed and tripped an assert when destroying the compositor instance. Signed-off-by: Marius Vlad --- libweston/backend-rdp/rdp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libweston/backend-rdp/rdp.c b/libweston/backend-rdp/rdp.c index 77e4edfd..8e333f4c 100644 --- a/libweston/backend-rdp/rdp.c +++ b/libweston/backend-rdp/rdp.c @@ -1297,6 +1297,8 @@ rdp_backend_create(struct weston_compositor *compositor, char *fd_tail; int fd, ret; + struct weston_head *base, *next; + b = zalloc(sizeof *b); if (b == NULL) return NULL; @@ -1369,8 +1371,12 @@ rdp_backend_create(struct weston_compositor *compositor, err_listener: freerdp_listener_free(b->listener); err_output: - weston_output_release(&b->output->base); + if (b->output) + weston_output_release(&b->output->base); err_compositor: + wl_list_for_each_safe(base, next, &compositor->head_list, compositor_link) + rdp_head_destroy(to_rdp_head(base)); + weston_compositor_shutdown(compositor); err_free_strings: free(b->rdp_key);