Skip to content

Commit 00625a6

Browse files
authored
Fix RTDB crash from race (#9123)
1 parent f318406 commit 00625a6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

FirebaseDatabase/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# v8.11.0
2+
- [fixed] Race condition crash in FUtilities.m. (#9096)
3+
14
# v8.10.0
25
- [fixed] Fixed URL handling bug when path is a substring of host. (#8874)
36

FirebaseDatabase/Sources/Utilities/FUtilities.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,11 @@ + (NSError *)errorForStatus:(NSString *)status andReason:(NSString *)reason {
295295
}
296296

297297
+ (NSNumber *)intForString:(NSString *)string {
298-
static NSCharacterSet *notDigits = nil;
299-
if (!notDigits) {
300-
notDigits = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
301-
}
298+
static dispatch_once_t once;
299+
static NSCharacterSet *notDigits;
300+
dispatch_once(&once, ^{
301+
notDigits = [[NSCharacterSet decimalDigitCharacterSet] invertedSet];
302+
});
302303
if ([string rangeOfCharacterFromSet:notDigits].length == 0) {
303304
NSInteger num;
304305
NSScanner *scanner = [NSScanner scannerWithString:string];

0 commit comments

Comments
 (0)