Skip to content

Commit 1742de0

Browse files
authored
Synchronize access to active path (#8127)
1 parent e221a50 commit 1742de0

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Crashlytics/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Unreleased
2-
- [changed] Incorporated code quality changes around integer overflow and reinstalling signal handlers.
2+
- [changed] Incorporated code quality changes around integer overflow, potential race conditions, and reinstalling signal handlers.
33

44
# v8.0.0
55
- [changed] Added a warning to upload-symbols when it detects a dSYM with hidden symbols.

Crashlytics/Crashlytics/Components/FIRCLSUserLogging.m

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
NSString *const FIRCLSDevelopmentPlatformVersionKey =
3434
@"com.crashlytics.development-platform-version";
3535

36+
// Empty string object synchronized on to prevent a race condition when accessing AB file path
37+
NSString *const FIRCLSSynchronizedPathKey = @"";
38+
3639
const uint32_t FIRCLSUserLoggingMaxKVEntries = 64;
3740

3841
#pragma mark - Prototypes
@@ -488,7 +491,9 @@ void FIRCLSUserLoggingCheckAndSwapABFiles(FIRCLSUserLoggingABStorage *storage,
488491
[[NSFileManager defaultManager] removeItemAtPath:pathString error:nil];
489492
}
490493

491-
*activePath = otherPath;
494+
@synchronized(FIRCLSSynchronizedPathKey) {
495+
*activePath = otherPath;
496+
}
492497
}
493498

494499
void FIRCLSUserLoggingWriteAndCheckABFiles(FIRCLSUserLoggingABStorage *storage,
@@ -498,8 +503,10 @@ void FIRCLSUserLoggingWriteAndCheckABFiles(FIRCLSUserLoggingABStorage *storage,
498503
return;
499504
}
500505

501-
if (!*activePath) {
502-
return;
506+
@synchronized(FIRCLSSynchronizedPathKey) {
507+
if (!*activePath) {
508+
return;
509+
}
503510
}
504511

505512
if (storage->restrictBySize) {

0 commit comments

Comments
 (0)