Skip to content

Commit a013f9c

Browse files
committed
Fixed data race issue inside GCDWebServerGetMimeTypeForExtension()
Fix swisspol#312
1 parent 1e28aef commit a013f9c

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

GCDWebServer/Core/GCDWebServerFunctions.m

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,11 @@ BOOL GCDWebServerIsTextContentType(NSString* type) {
167167
}
168168

169169
NSString* GCDWebServerGetMimeTypeForExtension(NSString* extension) {
170-
static NSDictionary* _overrides = nil;
171-
if (_overrides == nil) {
172-
_overrides = [[NSDictionary alloc] initWithObjectsAndKeys:
173-
@"text/css", @"css",
174-
nil];
175-
}
170+
NSDictionary* overrides = @{@"css": @"text/css"};
176171
NSString* mimeType = nil;
177172
extension = [extension lowercaseString];
178173
if (extension.length) {
179-
mimeType = [_overrides objectForKey:extension];
174+
mimeType = [overrides objectForKey:extension];
180175
if (mimeType == nil) {
181176
CFStringRef uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)extension, NULL);
182177
if (uti) {

0 commit comments

Comments
 (0)