rust/cargo-c: update to 0.10.7+cargo-0.84.0
[oi-userland.git] / components / x11 / libX11 / patches / 04.4010755.patch
blob106ea3555a936e2f5c26f7bcce63a680ae2a69d1
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 4010755: SEGV in XFindContext if XInitThreads has been enabled
26 XFindContext in Xlib was calling _XLockMutex with an uninitialized
27 mutex lock structure. The new version of XInitThreads activates the
28 locking functions at any time, even after displays have been created.
30 In this new case, the context structure was created prior to
31 XInitThreads being invoked. As a result, the display contained an
32 opaque pointer to this context structure, which still contained an
33 uninitialized lock structure.
35 The solution was to explicitly set the lock structure pointer to NULL
36 (as a flag) when creating the context, then check for NULL when
37 locking. If NULL is found and threads are now enabled, then the
38 structure gets reinitialized to the correct mutex lock structure
39 in the lock call.
41 Another area besides the functions in Context.c are the functions in
42 Xrm.c. A similar fix was added to them as well.
45 diff --git a/src/Context.c b/src/Context.c
46 index 8a07871..dd4df6b 100644
47 --- a/src/Context.c
48 +++ b/src/Context.c
49 @@ -190,6 +190,9 @@ int XSaveContext(
50 return XCNOMEM;
52 db->numentries = 0;
53 +#ifdef SUNSOFT
54 + db->linfo.lock = (xmutex_t) NULL;
55 +#endif
56 _XCreateMutex(&db->linfo);
57 #ifdef MOTIFBC
58 if (!display) *pdb = db; else
59 diff --git a/src/Xrm.c b/src/Xrm.c
60 index 36b71d6..b3283e6 100644
61 --- a/src/Xrm.c
62 +++ b/src/Xrm.c
63 @@ -497,6 +497,9 @@ static XrmDatabase NewDatabase(void)
65 db = Xmalloc(sizeof(XrmHashBucketRec));
66 if (db) {
67 +#ifdef SUNSOFT
68 + db->linfo.lock = (xmutex_t) NULL;
69 +#endif
70 _XCreateMutex(&db->linfo);
71 db->table = (NTable)NULL;
72 db->mbstate = (XPointer)NULL;
73 diff --git a/src/locking.c b/src/locking.c
74 index e4e0444..eb875e3 100644
75 --- libX11-1.6.2/src/locking.c.~2~ 2015-02-04 10:00:11.175372726 +0300
76 +++ libX11-1.6.2/src/locking.c 2015-02-04 10:04:59.050279588 +0300
77 @@ -99,11 +99,24 @@
78 static LockInfoRec global_lock;
79 static LockInfoRec i18n_lock;
81 +#ifdef SUNSOFT
82 +static void _XCreateMutex(LockInfoPtr lip); /* Forward declaration */
83 +#endif
85 static void _XLockMutex(
86 LockInfoPtr lip
87 XTHREADS_FILE_LINE_ARGS
90 +#ifdef SUNSOFT
91 + /* Make sure any locks in structures that were created before calling
92 + * XInitThreads are initialized before locking, now that we allow calls
93 + * to XInitThreads after other Xlib calls (Sun bugs 1234757 & 4010755)
94 + */
95 + if (lip->lock == NULL) {
96 + _XCreateMutex(lip);
97 + }
98 +#endif /* SUNSOFT */
99 xmutex_lock(lip->lock);