File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ 2026-06-16 Richard Frith-Macdonald <rfm@gnu.org>
2+
3+ * Source/NSLog.m: Fix race condition in lock setup reported by
4+ DTW-Thalion. Set up cached methods for lock before setting the
5+ variable itself.
6+
172026-06-13 Richard Frith-Macdonald <rfm@gnu.org>
28
39 * Headers/GNUstepBase/GSObjCRuntime.h:
Original file line number Diff line number Diff line change 9999NSRecursiveLock *
100100GSLogLock ()
101101{
102- if (myLock == nil )
102+ if (nil == myLock )
103103 {
104104 static gs_mutex_t setupLock = GS_MUTEX_INIT_STATIC ;
105105
106106 GS_MUTEX_LOCK (setupLock);
107- if (myLock == nil )
107+ if (nil == myLock )
108108 {
109- myLock = [NSRecursiveLock new ];
110- lockImp = [myLock methodForSelector: @selector (lock )];
111- unlockImp = [myLock methodForSelector: @selector (unlock )];
109+ NSRecursiveLock *tmp;
110+
111+ /* Avoid race condition by caching method implementations
112+ * before setting value in myLock
113+ */
114+ tmp = [NSRecursiveLock new ];
115+ lockImp = [tmp methodForSelector: @selector (lock )];
116+ unlockImp = [tmp methodForSelector: @selector (unlock )];
117+ myLock = tmp;
112118 }
113119 GS_MUTEX_UNLOCK (setupLock);
114120 }
You can’t perform that action at this time.
0 commit comments