Skip to content

Commit

Permalink
Avoid crashing in SentryCoreDataTracker
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bjhomer authored Jul 14, 2023
1 parent d760c3f commit 59161ef
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/Sentry/SentryCoreDataTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ - (NSArray *)managedObjectContext:(NSManagedObjectContext *)context
finishWithStatus:result == nil ? kSentrySpanStatusInternalError : kSentrySpanStatusOk];

SENTRY_LOG_DEBUG(@"SentryCoreDataTracker automatically finished span with status: %@",
error == nil ? @"ok" : @"error");
result == nil ? @"error" : @"ok");
}

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

SENTRY_LOG_DEBUG(@"SentryCoreDataTracker automatically finished span with status: %@",
*error == nil ? @"ok" : @"error");
result ? @"ok" : @"error");
}

return result;
Expand Down

0 comments on commit 59161ef

Please sign in to comment.