rust/cargo-c: update to 0.10.7+cargo-0.84.0
[oi-userland.git] / components / x11 / libX11 / patches / 05.4614834.patch
blobef3c8b845713696a25ac2bb289ee6f8c523d9810
1 ###############################################################################
2 # Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
4 # Permission is hereby granted, free of charge, to any person obtaining a
5 # copy of this software and associated documentation files (the "Software"),
6 # to deal in the Software without restriction, including without limitation
7 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 # and/or sell copies of the Software, and to permit persons to whom the
9 # Software is furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice (including the next
12 # paragraph) shall be included in all copies or substantial portions of the
13 # Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 # DEALINGS IN THE SOFTWARE.
24 4614834: Xlib color functions are not MT-safe
26 In a multithreaded Xlib client:
28 * concurrent access to XAllocNamedColor() make the client crash
29 * concurrent access to XLookupColor() make the client crash
31 The cause of the problem is that in multithread environment some data
32 in XLookupColor() and XAllocNamedColor() can be accessed/modified at
33 same time by multi threads. Adding some lock and unlock code to make
34 sure only one thread can access the data at one time fixed the
35 problem.
37 diff --git a/src/GetColor.c b/src/GetColor.c
38 index cd0eb9f..62b3bce 100644
39 --- a/src/GetColor.c
40 +++ b/src/GetColor.c
41 @@ -55,12 +55,14 @@ XColor *exact_def) /* RETURN */
42 if ((ccc = XcmsCCCOfColormap(dpy, cmap)) != (XcmsCCC)NULL) {
43 const char *tmpName = colorname;
45 + LockDisplay(dpy);
46 switch (_XcmsResolveColorString(ccc, &tmpName, &cmsColor_exact,
47 XcmsRGBFormat)) {
48 case XcmsSuccess:
49 case XcmsSuccessWithCompression:
50 _XcmsRGB_to_XColor(&cmsColor_exact, exact_def, 1);
51 memcpy((char *)hard_def, (char *)exact_def, sizeof(XColor));
52 + UnlockDisplay(dpy);
53 ret = XAllocColor(dpy, cmap, hard_def);
54 exact_def->pixel = hard_def->pixel;
55 return(ret);
56 @@ -73,6 +75,7 @@ XColor *exact_def) /* RETURN */
58 break;
60 + UnlockDisplay(dpy);
62 #endif
64 diff --git a/src/LookupCol.c b/src/LookupCol.c
65 index f7f969f..718e043 100644
66 --- a/src/LookupCol.c
67 +++ b/src/LookupCol.c
68 @@ -53,6 +53,7 @@ XLookupColor (
69 if ((ccc = XcmsCCCOfColormap(dpy, cmap)) != (XcmsCCC)NULL) {
70 const char *tmpName = spec;
72 + LockDisplay(dpy);
73 switch (_XcmsResolveColorString(ccc, &tmpName, &cmsColor_exact,
74 XcmsRGBFormat)) {
75 case XcmsSuccess:
76 @@ -60,6 +61,7 @@ XLookupColor (
77 _XcmsRGB_to_XColor(&cmsColor_exact, def, 1);
78 memcpy((char *)scr, (char *)def, sizeof(XColor));
79 _XUnresolveColor(ccc, scr);
80 + UnlockDisplay(dpy);
81 return(1);
82 case XcmsFailure:
83 case _XCMS_NEWNAME:
84 @@ -70,6 +72,7 @@ XLookupColor (
86 break;
88 + UnlockDisplay(dpy);
90 #endif