Skip to content

Commit

Permalink
Merge a2d7884 into 61c10bc
Browse files Browse the repository at this point in the history
  • Loading branch information
paulb777 authored May 17, 2024
2 parents 61c10bc + a2d7884 commit 5e85f0b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions FirebasePerformance/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Unreleased
- Fix Crash from InstrumentUploadTaskWithStreamedRequest (#12983).

# 10.25.0
- [changed] Removed usages of user defaults API to eliminate required reason impact.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,15 @@ void InstrumentUploadTaskWithStreamedRequest(FPRNSURLSessionInstrument *instrume
if (!strongInstrument) {
ThrowExceptionBecauseInstrumentHasBeenDeallocated(selector, instrumentor.instrumentedClass);
}
typedef NSURLSessionUploadTask *(*OriginalImp)(id, SEL, NSURLRequest *);
NSURLSessionUploadTask *uploadTask = ((OriginalImp)currentIMP)(session, selector, request);
typedef NSURLSessionUploadTask *(*OriginalImp)(id, SEL, NSURLRequest *, NSData *);
// To avoid a runtime warning in Xcode 15, the given `URLRequest`
// should have a nil `HTTPBody`. To workaround this, the `HTTPBody` data is removed
// and requestData is replaced with it, if it bodyData was `nil`.
NSMutableURLRequest *requestWithoutHTTPBody = [request mutableCopy];
NSData *requestData = requestWithoutHTTPBody.HTTPBody;
requestWithoutHTTPBody.HTTPBody = nil;
NSURLSessionUploadTask *uploadTask =
((OriginalImp)currentIMP)(session, selector, request, requestData);
if (uploadTask.originalRequest) {
FPRNetworkTrace *trace =
[[FPRNetworkTrace alloc] initWithURLRequest:uploadTask.originalRequest];
Expand Down

0 comments on commit 5e85f0b

Please sign in to comment.