prefs should not create empty dictionary for KIM_OPTIONS_DEFAULT
authorAlexandra Ellwood <lxs@mit.edu>
Thu, 9 Oct 2008 19:15:27 +0000 (19:15 +0000)
committerAlexandra Ellwood <lxs@mit.edu>
Thu, 9 Oct 2008 19:15:27 +0000 (19:15 +0000)
ticket: new

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20855 dc483132-0cff-0310-8789-dd5450dbe970

src/kim/lib/mac/kim_os_preferences.c

index 0b48a7fbb16926c78b754e4bba603b81e719b806..87700ef89f965fddf54427cdaf387abb3c95af9f 100644 (file)
@@ -226,7 +226,7 @@ static kim_error kim_os_preferences_set_value (kim_preference_key in_key,
     kim_error err = KIM_NO_ERROR;
     CFStringRef key = NULL;
     
-    if (!err && !in_value) { err = check_error (KIM_NULL_PARAMETER_ERR); }
+    /* in_value may be NULL if removing the key */
     
     if (!err) {
         key = kim_os_preferences_cfstring_for_key (in_key);
@@ -890,18 +890,19 @@ kim_error kim_os_preferences_set_options_for_key (kim_preference_key in_key,
     
     /* in_options may be KIM_OPTIONS_DEFAULT, in which case we empty the dict */
     
-    if (!err) {
+    if (!err && in_options) {
         dictionary = CFDictionaryCreateMutable (kCFAllocatorDefault, 0, 
                                                 &kCFTypeDictionaryKeyCallBacks,
                                                 &kCFTypeDictionaryValueCallBacks);
         if (!dictionary) { err = check_error (KIM_OUT_OF_MEMORY_ERR); }
-    }
-    
-    if (!err && in_options) {
-        err = kim_os_preferences_options_to_dictionary (in_options, dictionary);
+
+        if (!err) {
+            err = kim_os_preferences_options_to_dictionary (in_options, dictionary);
+        }
     }
     
     if (!err) {
+        /* NULL dictioray will remove any entry for this key */
         err = kim_os_preferences_set_value (in_key, dictionary);
     }