From 679f44b3d257152a5beaee4ce7d8cf9b8f882b3b Mon Sep 17 00:00:00 2001 From: Takeru Chuganji Date: Thu, 14 Feb 2019 14:16:06 -0800 Subject: [PATCH] Leak mutex to avoid a crashing issue (#22607) Summary: Try to solve https://github.com/facebook/react-native/issues/13588 ref: https://github.com/facebook/componentkit/pull/906 Pull Request resolved: https://github.com/facebook/react-native/pull/22607 Differential Revision: D14084056 Pulled By: shergin fbshipit-source-id: 585aef758e1a215e825ae12914c5011d790a69b0 --- 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 9cd63ce6ffe188..414e47c65c206a 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]; } }