xwayland: Fix leak of xwl_screen on init

On screen init, if any of the private type registration fails we would
return FALSE without actually freeing the xwl_screen we just allocated.

This is not a serious leak as failure at that point would lead to the
premature termination of Xwayland at startup, but covscan complains and
it's easy enough to fix.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
This commit is contained in:
Olivier Fourdan 2021-09-14 16:14:57 +02:00
parent 72c5d153c9
commit 138d4eba7b

View File

@ -549,10 +549,6 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
Bool use_eglstreams = FALSE;
#endif
xwl_screen = calloc(1, sizeof *xwl_screen);
if (xwl_screen == NULL)
return FALSE;
if (!dixRegisterPrivateKey(&xwl_screen_private_key, PRIVATE_SCREEN, 0))
return FALSE;
if (!xwl_pixmap_init())
@ -567,6 +563,10 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
sizeof(struct xwl_client)))
return FALSE;
xwl_screen = calloc(1, sizeof *xwl_screen);
if (xwl_screen == NULL)
return FALSE;
dixSetPrivate(&pScreen->devPrivates, &xwl_screen_private_key, xwl_screen);
xwl_screen->screen = pScreen;