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

Problem with deleteItemForUsername in SFHFKeychainUtils.m #5

Open
arielitovsky opened this issue Mar 15, 2011 · 2 comments
Open

Problem with deleteItemForUsername in SFHFKeychainUtils.m #5

arielitovsky opened this issue Mar 15, 2011 · 2 comments

Comments

@arielitovsky
Copy link

The line (423 on
if (error != nil && status != noErr)

Should be
if (error != nil || status != noErr)

Because it is possible for the error to be nil but for the status to return something different. In that case (e.g. the item was not found) we would want to return NO

@danyowdee
Copy link
Contributor

That would be incorrect as well:
When error != nil, your clause evaluates to YES regardless of the value of status. Hence the method returns NO — even if the operation succeeded!
In fact, it's even harmful:
When error == nil and status != noErr, your clause evaluates to YES, i.e. *error means *nil, which crashes with a segfault.

So in essence, status != noErr is necessary and sufficient for the method to return NO, while error != nil is neither. It is, however, necessary for the assignment *error = ... to behave correctly.

@stuffmc
Copy link

stuffmc commented Nov 25, 2012

As a side note, I totally don't understand why but although no errors are reported, the item isn't deleted from the keychain :( On 10.8.2 (Mac) — any idea? Someone mind testing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants