Skip to content

Commit

Permalink
fix: check if UTI exists (#272)
Browse files Browse the repository at this point in the history
Fixes a crash if UTI is null on Mac M1 simulators:
  • Loading branch information
nkovacic committed Aug 26, 2021
1 parent 11040cf commit b9ac083
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ios/VydiaRNFileUploader.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ - (void)_sendEventWithName:(NSString *)eventName body:(id)body {
- (NSString *)guessMIMETypeFromFileName: (NSString *)fileName {
CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)[fileName pathExtension], NULL);
CFStringRef MIMEType = UTTypeCopyPreferredTagWithClass(UTI, kUTTagClassMIMEType);
CFRelease(UTI);

if (UTI) {
CFRelease(UTI);
}

if (!MIMEType) {
return @"application/octet-stream";
}
Expand Down

0 comments on commit b9ac083

Please sign in to comment.