Skip to content

Commit

Permalink
Check returned Bundle ID for NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
glassez committed Aug 14, 2023
1 parent 72e947e commit c206539
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/base/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,8 @@ bool Preferences::isTorrentFileAssocSet()
if (defaultHandlerId != NULL)
{
const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
isSet = CFStringCompare(myBundleId, defaultHandlerId, 0) == kCFCompareEqualTo;
if (myBundleId != NULL)
isSet = CFStringCompare(myBundleId, defaultHandlerId, 0) == kCFCompareEqualTo;
CFRelease(defaultHandlerId);
}
CFRelease(torrentId);
Expand All @@ -1423,11 +1424,13 @@ void Preferences::setTorrentFileAssoc()
{
if (isTorrentFileAssocSet())
return;

const CFStringRef torrentId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, torrentExtension, NULL);
if (torrentId != NULL)
{
const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
LSSetDefaultRoleHandlerForContentType(torrentId, kLSRolesViewer, myBundleId);
if (myBundleId != NULL)
LSSetDefaultRoleHandlerForContentType(torrentId, kLSRolesViewer, myBundleId);
CFRelease(torrentId);
}
}
Expand All @@ -1439,7 +1442,8 @@ bool Preferences::isMagnetLinkAssocSet()
if (defaultHandlerId != NULL)
{
const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
isSet = CFStringCompare(myBundleId, defaultHandlerId, 0) == kCFCompareEqualTo;
if (myBundleId != NULL)
isSet = CFStringCompare(myBundleId, defaultHandlerId, 0) == kCFCompareEqualTo;
CFRelease(defaultHandlerId);
}
return isSet;
Expand All @@ -1449,8 +1453,10 @@ void Preferences::setMagnetLinkAssoc()
{
if (isMagnetLinkAssocSet())
return;

const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
LSSetDefaultHandlerForURLScheme(magnetUrlScheme, myBundleId);
if (myBundleId != NULL)
LSSetDefaultHandlerForURLScheme(magnetUrlScheme, myBundleId);
}
#endif // Q_OS_MACOS

Expand Down

0 comments on commit c206539

Please sign in to comment.