Skip to content

Commit 0871de4

Browse files
author
garenwang
committed
修复quic 偶现crash
1 parent 5d151f8 commit 0871de4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

QCloudQuic/Classes/QCloudBase/QCloudQuicDataTask.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ - (instancetype)initWithHTTPRequest:(NSMutableURLRequest *)httpRequest
7474
headerFileds:[quicHeaders copy]];
7575
_manager = [TquicConnection new];
7676
__weak typeof(self) weakSelf = self;
77+
__weak typeof(httpRequest) wHttpRequest = httpRequest;
7778
[_manager tquicConnectWithQuicRequest:req
7879
didConnect:^(NSError * _Nonnull error) {
7980
__strong typeof(weakSelf) strngSelf = weakSelf;
@@ -85,7 +86,9 @@ - (instancetype)initWithHTTPRequest:(NSMutableURLRequest *)httpRequest
8586
}
8687
} didReceiveResponse:^(TquicResponse *_Nonnull response) {
8788
__strong typeof(weakSelf) strngSelf = weakSelf;
88-
strngSelf.response = [[NSHTTPURLResponse alloc] initWithURL:httpRequest.URL
89+
__strong typeof(wHttpRequest) sHttpRequest = wHttpRequest;
90+
91+
strngSelf.response = [[NSHTTPURLResponse alloc] initWithURL:sHttpRequest.URL
8992
statusCode:response.statusCode
9093
HTTPVersion:response.httpVersion
9194
headerFields:[response.allHeaderFields copy]];
@@ -111,7 +114,8 @@ - (instancetype)initWithHTTPRequest:(NSMutableURLRequest *)httpRequest
111114
}
112115
RequestDidCompleteWithError:^(NSError *_Nonnull error) {
113116
__strong typeof(weakSelf) strngSelf = weakSelf;
114-
strngSelf.originalRequest = [[NSURLRequest alloc] initWithURL:httpRequest.URL];
117+
__strong typeof(wHttpRequest) sHttpRequest = wHttpRequest;
118+
strngSelf.originalRequest = [[NSURLRequest alloc] initWithURL:sHttpRequest.URL];
115119
if ([strngSelf.quicDelegate respondsToSelector:@selector(URLSession:task:didCompleteWithError:)]) {
116120
[strngSelf.quicDelegate URLSession:quicSession task:strngSelf didCompleteWithError:error];
117121
}

0 commit comments

Comments
 (0)