Skip to content

Commit

Permalink
Use dispatch_barrier_sync (AFNetworking#4474)
Browse files Browse the repository at this point in the history
This should hopefully avoid any problems where we attempt to write an
HTTP header to a deallocated header dictionary.

See AFNetworking#3891
See https://github.com/AFNetworking/AFNetworking/issues/3636
Modified from tmm1@32760e7

Fixes AFNetworking#1391
  • Loading branch information
streeter authored and jshier committed Jan 4, 2020
1 parent 5cf601c commit eb9ce0e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions AFNetworking/AFURLRequestSerialization.m
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ - (NSDictionary *)HTTPRequestHeaders {
- (void)setValue:(NSString *)value
forHTTPHeaderField:(NSString *)field
{
dispatch_barrier_async(self.requestHeaderModificationQueue, ^{
dispatch_barrier_sync(self.requestHeaderModificationQueue, ^{
[self.mutableHTTPRequestHeaders setValue:value forKey:field];
});
}
Expand All @@ -335,7 +335,7 @@ - (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username
}

- (void)clearAuthorizationHeader {
dispatch_barrier_async(self.requestHeaderModificationQueue, ^{
dispatch_barrier_sync(self.requestHeaderModificationQueue, ^{
[self.mutableHTTPRequestHeaders removeObjectForKey:@"Authorization"];
});
}
Expand Down

0 comments on commit eb9ce0e

Please sign in to comment.