Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a few errors that cause crashes #1523

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/utils/utils-mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,24 @@ bool get_auto_start()
#if (__MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10)
outURL = LSSharedFileListItemCopyResolvedURL(item, resolutionFlags, /*outError*/ NULL);
if (outURL == NULL) {
continue;
}
#else
OSStatus err = LSSharedFileListItemResolve(item, resolutionFlags, &outURL, /*outRef*/ NULL);
if (err != noErr || outURL == NULL) {
#endif
if (outURL)
CFRelease(outURL);
continue;
}
#endif
found = CFEqual(outURL, URLToToggle);
CFRelease(outURL);

if (found)
break;
}
CFRelease(currentLoginItems);
if (currentLoginItems)
CFRelease(currentLoginItems);
CFRelease(loginItems);
}
return found;
Expand Down Expand Up @@ -209,14 +212,16 @@ void set_auto_start(bool enabled)
#if (__MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10)
outURL = LSSharedFileListItemCopyResolvedURL(item, resolutionFlags, /*outError*/ NULL);
if (outURL == NULL) {
continue;
}
#else
OSStatus err = LSSharedFileListItemResolve(item, resolutionFlags, &outURL, /*outRef*/ NULL);
if (err != noErr || outURL == NULL) {
#endif
if (outURL)
CFRelease(outURL);
continue;
}
#endif
found = CFEqual(outURL, URLToToggle);
CFRelease(outURL);

Expand Down Expand Up @@ -258,7 +263,8 @@ void set_auto_start(bool enabled)
LSSharedFileListItemRemove(loginItems, existingItem);
}

CFRelease(currentLoginItems);
if (currentLoginItems)
CFRelease(currentLoginItems);
CFRelease(loginItems);
}
}
Expand Down