From d7089fd2a3560c6b8d733ed70d6414f2768059c5 Mon Sep 17 00:00:00 2001 From: Tyler Stromberg Date: Thu, 15 Mar 2012 00:16:28 -0400 Subject: [PATCH 1/3] Check for null error pointer before setting it on the invocation --- AFNetworking/AFJSONUtilities.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFJSONUtilities.m b/AFNetworking/AFJSONUtilities.m index 51241cf..83bb849 100644 --- a/AFNetworking/AFJSONUtilities.m +++ b/AFNetworking/AFJSONUtilities.m @@ -48,7 +48,9 @@ NSData * AFJSONEncode(id object, NSError **error) { NSUInteger serializeOptionFlags = 0; [invocation setArgument:&serializeOptionFlags atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation - [invocation setArgument:error atIndex:3]; + if (error != NULL) { + [invocation setArgument:error atIndex:3]; + } [invocation invoke]; [invocation getReturnValue:&data]; @@ -99,7 +101,9 @@ NSData * AFJSONEncode(id object, NSError **error) { [invocation setArgument:&object atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation NSUInteger writeOptions = 0; [invocation setArgument:&writeOptions atIndex:3]; - [invocation setArgument:error atIndex:4]; + if (error != NULL) { + [invocation setArgument:error atIndex:4]; + } [invocation invoke]; [invocation getReturnValue:&data]; From f7a00cfa5154c803bd24855a5ced9c09d1fd7cba Mon Sep 17 00:00:00 2001 From: Tyler Stromberg Date: Thu, 15 Mar 2012 00:23:37 -0400 Subject: [PATCH 2/3] Check in AFJSONDecode as well --- AFNetworking/AFJSONUtilities.m | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/AFNetworking/AFJSONUtilities.m b/AFNetworking/AFJSONUtilities.m index 83bb849..b7bb02f 100644 --- a/AFNetworking/AFJSONUtilities.m +++ b/AFNetworking/AFJSONUtilities.m @@ -142,7 +142,9 @@ id AFJSONDecode(NSData *data, NSError **error) { NSUInteger parseOptionFlags = 0; [invocation setArgument:&parseOptionFlags atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation - [invocation setArgument:error atIndex:3]; + if (error != NULL) { + [invocation setArgument:error atIndex:3]; + } [invocation invoke]; [invocation getReturnValue:&JSON]; @@ -162,7 +164,9 @@ id AFJSONDecode(NSData *data, NSError **error) { NSUInteger yajlParserOptions = 0; [invocation setArgument:&yajlParserOptions atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation - [invocation setArgument:error atIndex:3]; + if (error != NULL) { + [invocation setArgument:error atIndex:3]; + } [invocation invoke]; [invocation getReturnValue:&JSON]; @@ -173,7 +177,9 @@ id AFJSONDecode(NSData *data, NSError **error) { invocation.selector = _NXJsonParserSelector; [invocation setArgument:&data atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation - [invocation setArgument:error atIndex:3]; + if (error != NULL) { + [invocation setArgument:error atIndex:3]; + } [invocation setArgument:&nullOption atIndex:4]; [invocation invoke]; @@ -189,7 +195,9 @@ id AFJSONDecode(NSData *data, NSError **error) { [invocation setArgument:&data atIndex:2]; // arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation NSUInteger readOptions = 0; [invocation setArgument:&readOptions atIndex:3]; - [invocation setArgument:error atIndex:4]; + if (error != NULL) { + [invocation setArgument:error atIndex:4]; + } [invocation invoke]; [invocation getReturnValue:&JSON]; From 91d854a8a6c2cb1f1705d463a5fd56ee5f1546c2 Mon Sep 17 00:00:00 2001 From: James Gill Date: Thu, 15 Mar 2012 17:20:56 -0700 Subject: [PATCH 3/3] Fixing upload/download typo. --- AFNetworking/AFURLConnectionOperation.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/AFNetworking/AFURLConnectionOperation.h b/AFNetworking/AFURLConnectionOperation.h index 1dc96d0..14d0226 100644 --- a/AFNetworking/AFURLConnectionOperation.h +++ b/AFNetworking/AFURLConnectionOperation.h @@ -174,18 +174,18 @@ extern NSString * const AFNetworkingOperationDidFinishNotification; ///--------------------------------- /** - Sets a callback to be called when an undetermined number of bytes have been downloaded from the server. + Sets a callback to be called when an undetermined number of bytes have been uploaded to the server. - @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times. + @param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes three arguments: the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times. @see setDownloadProgressBlock */ - (void)setUploadProgressBlock:(void (^)(NSInteger bytesWritten, NSInteger totalBytesWritten, NSInteger totalBytesExpectedToWrite))block; /** - Sets a callback to be called when an undetermined number of bytes have been uploaded to the server. + Sets a callback to be called when an undetermined number of bytes have been downloaded from the server. - @param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes three arguments: the number of bytes read since the last time the upload progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times. + @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times. @see setUploadProgressBlock */