8000 Prevent systemPreferences.getUserDefault crash for missing arrays/dictionaries by kevinsawicki · Pull Request #7993 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Prevent systemPreferences.getUserDefault crash for missing arrays/dictionaries #7993

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

Merged
merged 2 commits into from
Nov 21, 2016

Conversation

kevinsawicki
Copy link
Contributor
@kevinsawicki kevinsawicki commented Nov 17, 2016

The NSArrayToListValue and NSDictionaryToDictionaryValue return null pointers when the given value is null which is the case when the requested user default is not an array or dictionary.

This pull requests returns empty array/objects instead of crashing when this happens.

Also adds specs for the values returned when the key has no default.

Fixes #7993

@anaisbetts
Copy link
Contributor

Would it be better to return undefined or null instead?

@kevinsawicki kevinsawicki changed the title Prevent getUserDefault crash for missing arrays and dictionaries Prevent systemPreferences.getUserDefault crash for missing arrays/dictionaries Nov 17, 2016
@kevinsawicki
Copy link
Contributor Author
kevinsawicki commented Nov 17, 2016

Would it be better to return undefined or null instead?

I thought about that a bit, it looks like numbers, booleans, strings, and urls return valid values instead of undefined/null when their missing so empty arrays/objects seemed to make it consistent with that existing behavior.

@anaisbetts
Copy link
Contributor

I thought about that a bit, it looks like numbers and booleans return valid values instead of undefined/null when they're missing

😢

@kevinsawicki kevinsawicki force-pushed the get-user-default-crash branch from 3063faf to 2613797 Compare November 21, 2016 17:22
@kevinsawicki kevinsawicki merged commit 82d17cb into master Nov 21, 2016
@kevinsawicki kevinsawicki deleted the get-user-default-crash branch November 21, 2016 17:50
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

Successfully merging this pull request may close these issues.

3 participants
0