add loop to catch null values

This commit is contained in:
Shelley Vohr 2017-12-13 14:02:43 -05:00
parent 6252ce466c
commit 3fc844c15a
No known key found for this signature in database
GPG key ID: F13993A75599653C
2 changed files with 8 additions and 7 deletions

View file

@ -152,13 +152,13 @@ void SystemPreferences::RegisterDefaults(mate::Arguments* args) {
} else {
@try {
NSDictionary* dict = DictionaryValueToNSDictionary(value);
// for (id key in dict) {
// id value = [dict objectForKey:key];
// if (value == nil) {
// printf("HELLO\n");
// args->ThrowError("Invalid userDefault data provided");
// }
// }
for (id key in dict) {
id value = [dict objectForKey:key];
if ([value isKindOfClass:[NSNull class]] || value == nil) {
args->ThrowError("Invalid userDefault data provided");
return;
}
}
[[NSUserDefaults standardUserDefaults] registerDefaults:dict];
} @catch (NSException* exception) {
args->ThrowError("Invalid userDefault data provided");

View file

@ -66,6 +66,7 @@ describe('systemPreferences module', () => {
1,
null,
new Date(),
{ 'one': null }
]
for (const badDefault of badDefaults) {