Skip to content

Commit c206539

Browse files
committed
Check returned Bundle ID for NULL
1 parent 72e947e commit c206539

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/base/preferences.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,8 @@ bool Preferences::isTorrentFileAssocSet()
14111411
if (defaultHandlerId != NULL)
14121412
{
14131413
const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
1414-
isSet = CFStringCompare(myBundleId, defaultHandlerId, 0) == kCFCompareEqualTo;
1414+
if (myBundleId != NULL)
1415+
isSet = CFStringCompare(myBundleId, defaultHandlerId, 0) == kCFCompareEqualTo;
14151416
CFRelease(defaultHandlerId);
14161417
}
14171418
CFRelease(torrentId);
@@ -1423,11 +1424,13 @@ void Preferences::setTorrentFileAssoc()
14231424
{
14241425
if (isTorrentFileAssocSet())
14251426
return;
1427+
14261428
const CFStringRef torrentId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, torrentExtension, NULL);
14271429
if (torrentId != NULL)
14281430
{
14291431
const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
1430-
LSSetDefaultRoleHandlerForContentType(torrentId, kLSRolesViewer, myBundleId);
1432+
if (myBundleId != NULL)
1433+
LSSetDefaultRoleHandlerForContentType(torrentId, kLSRolesViewer, myBundleId);
14311434
CFRelease(torrentId);
14321435
}
14331436
}
@@ -1439,7 +1442,8 @@ bool Preferences::isMagnetLinkAssocSet()
14391442
if (defaultHandlerId != NULL)
14401443
{
14411444
const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
1442-
isSet = CFStringCompare(myBundleId, defaultHandlerId, 0) == kCFCompareEqualTo;
1445+
if (myBundleId != NULL)
1446+
isSet = CFStringCompare(myBundleId, defaultHandlerId, 0) == kCFCompareEqualTo;
14431447
CFRelease(defaultHandlerId);
14441448
}
14451449
return isSet;
@@ -1449,8 +1453,10 @@ void Preferences::setMagnetLinkAssoc()
14491453
{
14501454
if (isMagnetLinkAssocSet())
14511455
return;
1456+
14521457
const CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
1453-
LSSetDefaultHandlerForURLScheme(magnetUrlScheme, myBundleId);
1458+
if (myBundleId != NULL)
1459+
LSSetDefaultHandlerForURLScheme(magnetUrlScheme, myBundleId);
14541460
}
14551461
#endif // Q_OS_MACOS
14561462

0 commit comments

Comments
 (0)