Skip to content

Commit

Permalink
check for errors before CFRelease (#20)
Browse files Browse the repository at this point in the history
macOS' SecKeychainFindGenericPassword can return a non-NULL item pointer
even if the function fails (because the item is not found). In this case
we must not try to CFRelease the item, or we'll segfault.
  • Loading branch information
hrantzsch authored Jan 2, 2020
1 parent dc18493 commit 48c78fc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion keychain_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void deletePassword(const std::string &package, const std::string &service,
}
}

if (item) {
if (!err && item) {
CFRelease(item);
}

Expand Down

0 comments on commit 48c78fc

Please sign in to comment.