Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.

Commit 9531290

Browse files
chuganzyJAStanton
authored andcommitted
Leak mutex to avoid a crashing issue (facebook#22607)
Summary: Try to solve facebook#13588 ref: facebook/componentkit#906 Pull Request resolved: facebook#22607 Differential Revision: D14084056 Pulled By: shergin fbshipit-source-id: 585aef758e1a215e825ae12914c5011d790a69b0
1 parent e8431c1 commit 9531290

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)