From b8e66131d6b1e9f950dc87369b83c320d8fdeb5b Mon Sep 17 00:00:00 2001 From: Takeru Chuganji Date: Tue, 11 Dec 2018 10:31:10 -0800 Subject: [PATCH] Leak mutex to avoid a crashing issue Ref: https://github.com/facebook/componentkit/pull/906 --- React/Views/RCTFont.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/React/Views/RCTFont.mm b/React/Views/RCTFont.mm index e26fcd89bc810b..d783722cc94c59 100644 --- a/React/Views/RCTFont.mm +++ b/React/Views/RCTFont.mm @@ -126,12 +126,12 @@ static inline BOOL CompareFontWeights(UIFontWeight firstWeight, UIFontWeight sec static UIFont *cachedSystemFont(CGFloat size, RCTFontWeight weight) { static NSCache *fontCache; - static std::mutex fontCacheMutex; + static std::mutex *fontCacheMutex = new std::mutex; NSString *cacheKey = [NSString stringWithFormat:@"%.1f/%.2f", size, weight]; UIFont *font; { - std::lock_guard lock(fontCacheMutex); + std::lock_guard lock(*fontCacheMutex); if (!fontCache) { fontCache = [NSCache new]; } @@ -158,7 +158,7 @@ static inline BOOL CompareFontWeights(UIFontWeight firstWeight, UIFontWeight sec } { - std::lock_guard lock(fontCacheMutex); + std::lock_guard lock(*fontCacheMutex); [fontCache setObject:font forKey:cacheKey]; } }