Changing return type of appendPartWithFileURL:name:error: to BOOL, according to Apple guidelines for methods that accept an NSError** parameter (Thanks, Zac Bowling)
Fixing issue with potential NULL dereference in setting error pointer
This commit is contained in:
parent
bb4aaa68fa
commit
648c650ae7
2 changed files with 13 additions and 4 deletions
|
|
@ -407,9 +407,11 @@ extern NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *paramete
|
|||
@param name The name to be associated with the specified data. This parameter must not be `nil`.
|
||||
@param error If an error occurs, upon return contains an `NSError` object that describes the problem.
|
||||
|
||||
@return `YES` if the file data was successfully appended, otherwise `NO`.
|
||||
|
||||
@discussion The filename and MIME type for this data in the form will be automatically generated, using `NSURLResponse` `-suggestedFilename` and `-MIMEType`, respectively.
|
||||
*/
|
||||
- (void)appendPartWithFileURL:(NSURL *)fileURL name:(NSString *)name error:(NSError **)error;
|
||||
- (BOOL)appendPartWithFileURL:(NSURL *)fileURL name:(NSString *)name error:(NSError **)error;
|
||||
|
||||
/**
|
||||
Appends encoded data to the form data.
|
||||
|
|
|
|||
|
|
@ -449,13 +449,16 @@ static inline NSString * AFMultipartFormFinalBoundary() {
|
|||
[self appendPartWithHeaders:mutableHeaders body:data];
|
||||
}
|
||||
|
||||
- (void)appendPartWithFileURL:(NSURL *)fileURL name:(NSString *)name error:(NSError **)error {
|
||||
- (BOOL)appendPartWithFileURL:(NSURL *)fileURL name:(NSString *)name error:(NSError **)error {
|
||||
if (![fileURL isFileURL]) {
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
||||
[userInfo setValue:fileURL forKey:NSURLErrorFailingURLErrorKey];
|
||||
[userInfo setValue:NSLocalizedString(@"Expected URL to be a file URL", nil) forKey:NSLocalizedFailureReasonErrorKey];
|
||||
*error = [[[NSError alloc] initWithDomain:AFNetworkingErrorDomain code:NSURLErrorBadURL userInfo:userInfo] autorelease];
|
||||
return;
|
||||
if (error != NULL) {
|
||||
*error = [[[NSError alloc] initWithDomain:AFNetworkingErrorDomain code:NSURLErrorBadURL userInfo:userInfo] autorelease];
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:fileURL];
|
||||
|
|
@ -466,6 +469,10 @@ static inline NSString * AFMultipartFormFinalBoundary() {
|
|||
|
||||
if (response && !error) {
|
||||
[self appendPartWithFileData:data name:name fileName:[response suggestedFilename] mimeType:[response MIMEType]];
|
||||
|
||||
return YES;
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue