dix: Fix segfault if CreateGC() failed in XaceHook()
CreateGC() allocates a new GC and then checks the resource access rights with XaceHook(). If the call to XaceHook() fails (i.e. GC creation is not granted to the client), CreateGC() exits early and calls FreeGC() to avoid leaking the newly allocated GC. If that happens, the screen's own CreateGC() has not yet been invoked, and as a result the GC functions (GCfuncs) have not been set yet. FreeGC() will invoke the funcs->DestroyClip() and the funcs->DestroyGC() functions, but since those haven't been set, the Xserver will segfault trying to call a NULL function. To prevent that issue, make sure the GC's functions are initialized prior to call them in FreeGC(). Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1625 Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
This commit is contained in:
parent
9c7c470b12
commit
e62246641b
2
dix/gc.c
2
dix/gc.c
|
@ -770,6 +770,7 @@ FreeGC(void *value, XID gid)
|
|||
GCPtr pGC = (GCPtr) value;
|
||||
|
||||
CloseFont(pGC->font, (Font) 0);
|
||||
if (pGC->funcs)
|
||||
(*pGC->funcs->DestroyClip) (pGC);
|
||||
|
||||
if (!pGC->tileIsPixel)
|
||||
|
@ -777,6 +778,7 @@ FreeGC(void *value, XID gid)
|
|||
if (pGC->stipple)
|
||||
(*pGC->pScreen->DestroyPixmap) (pGC->stipple);
|
||||
|
||||
if (pGC->funcs)
|
||||
(*pGC->funcs->DestroyGC) (pGC);
|
||||
if (pGC->dash != DefaultDash)
|
||||
free(pGC->dash);
|
||||
|
|
Loading…
Reference in New Issue