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:
		
							parent
							
								
									72c5d153c9
								
							
						
					
					
						commit
						138d4eba7b
					
				| 
						 | 
					@ -549,10 +549,6 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
 | 
				
			||||||
    Bool use_eglstreams = FALSE;
 | 
					    Bool use_eglstreams = FALSE;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    xwl_screen = calloc(1, sizeof *xwl_screen);
 | 
					 | 
				
			||||||
    if (xwl_screen == NULL)
 | 
					 | 
				
			||||||
        return FALSE;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (!dixRegisterPrivateKey(&xwl_screen_private_key, PRIVATE_SCREEN, 0))
 | 
					    if (!dixRegisterPrivateKey(&xwl_screen_private_key, PRIVATE_SCREEN, 0))
 | 
				
			||||||
        return FALSE;
 | 
					        return FALSE;
 | 
				
			||||||
    if (!xwl_pixmap_init())
 | 
					    if (!xwl_pixmap_init())
 | 
				
			||||||
| 
						 | 
					@ -567,6 +563,10 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
 | 
				
			||||||
                               sizeof(struct xwl_client)))
 | 
					                               sizeof(struct xwl_client)))
 | 
				
			||||||
        return FALSE;
 | 
					        return FALSE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    xwl_screen = calloc(1, sizeof *xwl_screen);
 | 
				
			||||||
 | 
					    if (xwl_screen == NULL)
 | 
				
			||||||
 | 
					        return FALSE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    dixSetPrivate(&pScreen->devPrivates, &xwl_screen_private_key, xwl_screen);
 | 
					    dixSetPrivate(&pScreen->devPrivates, &xwl_screen_private_key, xwl_screen);
 | 
				
			||||||
    xwl_screen->screen = pScreen;
 | 
					    xwl_screen->screen = pScreen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue