Explorar o código

Protect against a nil NSURLConnection or NSURLSession object being passed to the swizzled delegate methods.

See https://github.com/Flipboard/FLEX/issues/61 for motivation and background.
Ryan Olson %!s(int64=11) %!d(string=hai) anos
pai
achega
a42af79040
Modificáronse 1 ficheiros con 8 adicións e 0 borrados
  1. 8 0
      Classes/Network/PonyDebugger/FLEXNetworkObserver.m

+ 8 - 0
Classes/Network/PonyDebugger/FLEXNetworkObserver.m

@@ -149,6 +149,14 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
 /// The superclass implementation (and implementations in classes above that) will be executed without inteference if called from the original implementation.
 + (void)sniffWithoutDuplicationForObject:(NSObject *)object selector:(SEL)selector sniffingBlock:(void (^)(void))sniffingBlock originalImplementationBlock:(void (^)(void))originalImplementationBlock
 {
+    // If we don't have an object to detect nested calls on, just run the original implmentation and bail.
+    // This case can happen if someone besides the URL loading system calls the delegate methods directly.
+    // See https://github.com/Flipboard/FLEX/issues/61 for an example.
+    if (!object) {
+        originalImplementationBlock();
+        return;
+    }
+
     const void *key = selector;
 
     // Don't run the sniffing block if we're inside a nested call