Skip to content

Commit b8e6613

Browse files
committed
Leak mutex to avoid a crashing issue
Ref: facebook/componentkit#906
1 parent 0314fca commit b8e6613

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

React/Views/RCTFont.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ static inline BOOL CompareFontWeights(UIFontWeight firstWeight, UIFontWeight sec
126126
static UIFont *cachedSystemFont(CGFloat size, RCTFontWeight weight)
127127
{
128128
static NSCache *fontCache;
129-
static std::mutex fontCacheMutex;
129+
static std::mutex *fontCacheMutex = new std::mutex;
130130

131131
NSString *cacheKey = [NSString stringWithFormat:@"%.1f/%.2f", size, weight];
132132
UIFont *font;
133133
{
134-
std::lock_guard<std::mutex> lock(fontCacheMutex);
134+
std::lock_guard<std::mutex> lock(*fontCacheMutex);
135135
if (!fontCache) {
136136
fontCache = [NSCache new];
137137
}
@@ -158,7 +158,7 @@ static inline BOOL CompareFontWeights(UIFontWeight firstWeight, UIFontWeight sec
158158
}
159159

160160
{
161-
std::lock_guard<std::mutex> lock(fontCacheMutex);
161+
std::lock_guard<std::mutex> lock(*fontCacheMutex);
162162
[fontCache setObject:font forKey:cacheKey];
163163
}
164164
}

0 commit comments

Comments
 (0)