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

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

Merged
merged 2 commits into from Nov 21, 2016

Conversation

Projects
None yet
3 participants
@kevinsawicki
Contributor

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

@paulcbetts

This comment has been minimized.

Show comment
Hide comment
@paulcbetts

paulcbetts Nov 17, 2016

Contributor

Would it be better to return undefined or null instead?

Contributor

paulcbetts commented Nov 17, 2016

Would it be better to return undefined or null instead?

@kevinsawicki kevinsawicki changed the title from Prevent getUserDefault crash for missing arrays and dictionaries to Prevent systemPreferences.getUserDefault crash for missing arrays/dictionaries Nov 17, 2016

@kevinsawicki

This comment has been minimized.

Show comment
Hide comment
@kevinsawicki

kevinsawicki Nov 17, 2016

Contributor

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.

Contributor

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.

@paulcbetts

This comment has been minimized.

Show comment
Hide comment
@paulcbetts

paulcbetts Nov 17, 2016

Contributor

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

😢

Contributor

paulcbetts commented Nov 17, 2016

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

😢

@zeke

zeke approved these changes Nov 18, 2016

@kevinsawicki kevinsawicki merged commit 82d17cb into master Nov 21, 2016

7 of 9 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
electron-linux-arm Build #4745435 succeeded in 64s
Details
electron-linux-ia32 Build #4745436 succeeded in 59s
Details
electron-linux-x64 Build #4745437 succeeded in 124s
Details
electron-mas-x64 Build #2861 succeeded in 7 min 1 sec
Details
electron-osx-x64 Build #2872 succeeded in 8 min 40 sec
Details
electron-win-ia32 Build #1935 succeeded in 10 min
Details
electron-win-x64 Build #1906 succeeded in 10 min
Details

@kevinsawicki kevinsawicki deleted the get-user-default-crash branch Nov 21, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment