Jelajahi Sumber

Fix analyzer warning about NULL dereference.

Jeff Kelley 7 tahun lalu
induk
melakukan
20ff51cb8e

+ 3 - 1
Tests/Tests/AFHTTPRequestSerializationTests.m

@@ -169,7 +169,9 @@
     NSError *serializerError = [NSError errorWithDomain:@"TestDomain" code:0 userInfo:nil];
 
     [serializer setQueryStringSerializationWithBlock:^NSString *(NSURLRequest *request, NSDictionary *parameters, NSError *__autoreleasing *error) {
-        *error = serializerError;
+        if (error != NULL) {
+            *error = serializerError;
+        }
         return nil;
     }];
 

+ 3 - 1
Tests/Tests/AFHTTPSessionManagerTests.m

@@ -178,7 +178,9 @@
     XCTestExpectation *expectation = [self expectationWithDescription:@"Serialization should fail"];
 
     [self.manager.requestSerializer setQueryStringSerializationWithBlock:^NSString * _Nonnull(NSURLRequest * _Nonnull request, id  _Nonnull parameters, NSError * _Nullable __autoreleasing * _Nullable error) {
-        *error = [NSError errorWithDomain:@"Custom" code:-1 userInfo:nil];
+        if (error != NULL) {
+            *error = [NSError errorWithDomain:@"Custom" code:-1 userInfo:nil];
+        }
         return @"";
     }];