From e7bc1679c705cc8a23974fd30dfe8cd3a07e7d66 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Tue, 15 Apr 2014 13:20:56 -0700 Subject: [PATCH] Applying equivalent patch for 4c20a5ea38a50f119c9e8ac3d91fb199192a1d57, which fixes potential non-terminating loop in connection:didReceiveData: --- AFNetworking/AFURLConnectionOperation.m | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index e483f3e..5885369 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -739,16 +739,20 @@ didReceiveResponse:(NSURLResponse *)response while (totalNumberOfBytesWritten < length) { numberOfBytesWritten = [self.outputStream write:&dataBuffer[0] maxLength:length]; if (numberOfBytesWritten == -1) { - [self.connection cancel]; - [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:self.outputStream.streamError]; - return; - } else { - totalNumberOfBytesWritten += numberOfBytesWritten; + break; } + + totalNumberOfBytesWritten += numberOfBytesWritten; } break; } + + if (self.outputStream.streamError) { + [self.connection cancel]; + [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:self.outputStream.streamError]; + return; + } } dispatch_async(dispatch_get_main_queue(), ^{