Skip to content

Commit 812e3fc

Browse files
authored
add defensive check to anyTask.currentRequest in resume swizzling (#523)
1 parent 2796cc0 commit 812e3fc

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Sources/Instrumentation/URLSession/URLSessionInstrumentation.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ public class URLSessionInstrumentation {
353353
var originalIMP: IMP?
354354
let block: @convention(block) (URLSessionTask) -> Void = { anyTask in
355355
self.urlSessionTaskWillResume(anyTask)
356+
guard anyTask.currentRequest != nil else { return }
356357
let key = String(theMethod.hashValue)
357358
objc_setAssociatedObject(anyTask, key, true, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
358359
let castedIMP = unsafeBitCast(originalIMP, to: (@convention(c) (Any) -> Void).self)

0 commit comments

Comments
 (0)