From 34c6dc504bb1d437bbe1a4e212a0fd1839bb954d Mon Sep 17 00:00:00 2001 From: Sam Soffes Date: Wed, 29 Feb 2012 14:35:45 -0800 Subject: [PATCH] Avoid crash with `nil` URL in request --- AFNetworking/AFURLConnectionOperation.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 076d846..3056402 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -353,7 +353,10 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat [self.connection cancel]; // Manually send this delegate message since `[self.connection cancel]` causes the connection to never send another message to its delegate - NSDictionary *userInfo = [NSDictionary dictionaryWithObject:[self.request URL] forKey:NSURLErrorFailingURLErrorKey]; + NSDictionary *userInfo = nil; + if (self.request.URL) { + userInfo = [NSDictionary dictionaryWithObject:[self.request URL] forKey:NSURLErrorFailingURLErrorKey]; + } [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo]]; } }