summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarc_culler <marc.culler@gmail.com>2022-09-21 17:59:22 (GMT)
committermarc_culler <marc.culler@gmail.com>2022-09-21 17:59:22 (GMT)
commit0c682e76e15f569391daddd41dc963dee8829a60 (patch)
tree1ccf0f1e69cee678093fedc2c8236c38e362e804
parentfbda9c87baf1a96bb9cc195d99f465d3f3f2f3d6 (diff)
downloadtk-0c682e76e15f569391daddd41dc963dee8829a60.zip
tk-0c682e76e15f569391daddd41dc963dee8829a60.tar.gz
tk-0c682e76e15f569391daddd41dc963dee8829a60.tar.bz2
tkMacOSXFileTypes.c: Guard against crashes when a nil UTType is created.
-rw-r--r--macosx/tkMacOSXFileTypes.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/macosx/tkMacOSXFileTypes.c b/macosx/tkMacOSXFileTypes.c
index c89328d..c5beb67 100644
--- a/macosx/tkMacOSXFileTypes.c
+++ b/macosx/tkMacOSXFileTypes.c
@@ -77,15 +77,17 @@ MODULE_SCOPE NSImage *TkMacOSXIconForFileType(NSString *filetype) {
}
if (@available(macOS 11.0, *)) {
UTType *uttype = [UTType typeWithIdentifier: filetype];
- if (![uttype isDeclared]) {
+ if (uttype == nil || !uttype.isDeclared) {
uttype = [UTType typeWithFilenameExtension: filetype];
}
- if (![uttype isDeclared] && [filetype length] == 4) {
+ if (uttype == nil || (!uttype.isDeclared && filetype.length == 4)) {
OSType ostype = CHARS_TO_OSTYPE(filetype.UTF8String);
NSString *UTI = TkMacOSXOSTypeToUTI(ostype);
- uttype = [UTType typeWithIdentifier:UTI];
+ if (UTI) {
+ uttype = [UTType typeWithIdentifier:UTI];
+ }
}
- if (![uttype isDeclared]) {
+ if (uttype == nil || !uttype.isDeclared) {
return nil;
}
return [[NSWorkspace sharedWorkspace] iconForContentType:uttype];