From eb9ce0e23df467ecd4c1d6f80d1205ffea3bd8e0 Mon Sep 17 00:00:00 2001 From: Chris Streeter Date: Sat, 4 Jan 2020 15:24:33 -0800 Subject: [PATCH] Use dispatch_barrier_sync (#4474) This should hopefully avoid any problems where we attempt to write an HTTP header to a deallocated header dictionary. See https://github.com/AFNetworking/AFNetworking/pull/3891 See https://github.com/AFNetworking/AFNetworking/issues/3636 Modified from https://github.com/tmm1/AFNetworking/commit/32760e7a3a1cca2817ec498708182ec99584651a Fixes #1391 --- AFNetworking/AFURLRequestSerialization.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFURLRequestSerialization.m b/AFNetworking/AFURLRequestSerialization.m index 75672f2bda..f60b6f9d8a 100644 --- a/AFNetworking/AFURLRequestSerialization.m +++ b/AFNetworking/AFURLRequestSerialization.m @@ -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]; }); } @@ -335,7 +335,7 @@ - (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username } - (void)clearAuthorizationHeader { - dispatch_barrier_async(self.requestHeaderModificationQueue, ^{ + dispatch_barrier_sync(self.requestHeaderModificationQueue, ^{ [self.mutableHTTPRequestHeaders removeObjectForKey:@"Authorization"]; }); }