Skip to content

Commit 4386045

Browse files
authoredJul 17, 2023
Avoid crashing in SentryCoreDataTracker (#3152)
Users can pass in a `nil` error parameter when calling Core Data methods like `save:` and `executeFetchRequest:`. We were incorrectly handling that nil error parameter and trying to dereference it inside SENTRY_LOG_DEBUG calls. This commit fixes that. Fixes GH-3151
1 parent d760c3f commit 4386045

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎Sources/Sentry/SentryCoreDataTracker.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ - (NSArray *)managedObjectContext:(NSManagedObjectContext *)context
6767
finishWithStatus:result == nil ? kSentrySpanStatusInternalError : kSentrySpanStatusOk];
6868

6969
SENTRY_LOG_DEBUG(@"SentryCoreDataTracker automatically finished span with status: %@",
70-
error == nil ? @"ok" : @"error");
70+
result == nil ? @"error" : @"ok");
7171
}
7272

7373
return result;
@@ -109,7 +109,7 @@ - (BOOL)managedObjectContext:(NSManagedObjectContext *)context
109109
[fetchSpan finishWithStatus:result ? kSentrySpanStatusOk : kSentrySpanStatusInternalError];
110110

111111
SENTRY_LOG_DEBUG(@"SentryCoreDataTracker automatically finished span with status: %@",
112-
*error == nil ? @"ok" : @"error");
112+
result ? @"ok" : @"error");
113113
}
114114

115115
return result;

0 commit comments

Comments
 (0)