Protect colormap add/removal with display lock

This fixes a bug where concurrent threads call XCreateColormap and
XFreeColormap corrupting a linked list where colormap structures
are stored.

Fixes: https://gitlab.freedesktop.org/xorg/lib/libx11/issues/94

v2: handle XCopyColormapAndFree also (Adam Jackson)

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
This commit is contained in:
Tapani Pälli 2019-05-13 08:29:49 +03:00
parent fea80d03c3
commit 99a2cf1aa0
3 changed files with 9 additions and 9 deletions

View file

@ -53,12 +53,12 @@ Colormap XCopyColormapAndFree(
mid = req->mid = XAllocID(dpy);
req->srcCmap = src_cmap;
UnlockDisplay(dpy);
SyncHandle();
#if XCMS
_XcmsCopyCmapRecAndFree(dpy, src_cmap, mid);
#endif
UnlockDisplay(dpy);
SyncHandle();
return(mid);
}

View file

@ -48,12 +48,12 @@ Colormap XCreateColormap(
if (visual == CopyFromParent) req->visual = CopyFromParent;
else req->visual = visual->visualid;
UnlockDisplay(dpy);
SyncHandle();
#ifdef XCMS
_XcmsAddCmapRec(dpy, mid, w, visual);
#endif
UnlockDisplay(dpy);
SyncHandle();
return(mid);
}

View file

@ -41,12 +41,12 @@ XFreeColormap(
LockDisplay(dpy);
GetResReq(FreeColormap, cmap, req);
UnlockDisplay(dpy);
SyncHandle();
#ifdef XCMS
_XcmsDeleteCmapRec(dpy, cmap);
#endif
UnlockDisplay(dpy);
SyncHandle();
return 1;
}