Fixed a bug where kim_preferences_remove_favorite_identity
authorAlexandra Ellwood <lxs@mit.edu>
Thu, 25 Sep 2008 20:25:40 +0000 (20:25 +0000)
committerAlexandra Ellwood <lxs@mit.edu>
Thu, 25 Sep 2008 20:25:40 +0000 (20:25 +0000)
was removing the first identity which did not match the one
being passed in.

ticket: 6055

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

src/kim/lib/kim_preferences.c

index 8ec5fd16c68f38977643d245599113042e2121b0..46600922f27a17f0bf29901374e2ad70f6b97c8f 100644 (file)
@@ -249,18 +249,18 @@ kim_error kim_favorites_add_identity (kim_favorites io_favorites,
         kim_count i;
         
         for (i = 0; !err && i < io_favorites->count; i++) {
-            kim_comparison identity_comparison = 0;
+            kim_comparison comparison = 0;
             
             err = kim_identity_compare (io_favorites->identities[i],
                                         in_identity, 
-                                        &identity_comparison);
+                                        &comparison);
             
             if (!err) {
-                if (kim_comparison_is_greater_than (identity_comparison)) {
+                if (kim_comparison_is_greater_than (comparison)) {
                     /* insert before the first entry that is greater than us */
                     break; 
                     
-                } else if (kim_comparison_is_equal_to (identity_comparison)) {
+                } else if (kim_comparison_is_equal_to (comparison)) {
                     /* already in list */
                     kim_string display_string = NULL;
                     
@@ -313,7 +313,7 @@ kim_error kim_favorites_remove_identity (kim_favorites io_favorites,
                                          kim_identity  in_identity)
 {
     kim_error err = KIM_NO_ERROR;
-    kim_boolean found = FALSE;
+    kim_boolean found = 0;
     kim_count i;
     
     if (!err && !io_favorites) { err = check_error (KIM_NULL_PARAMETER_ERR); }
@@ -323,13 +323,16 @@ kim_error kim_favorites_remove_identity (kim_favorites io_favorites,
         for (i = 0; !err && !found && i < io_favorites->count; i++) {
             kim_identity identity = io_favorites->identities[i];
             kim_options options = io_favorites->options[i];
+            kim_comparison comparison;
             
-            err = kim_identity_compare (in_identity, identity, &found);
+            err = kim_identity_compare (in_identity, identity, &comparison);
             
-            if (!err && found) {
+            if (!err && kim_comparison_is_equal (comparison)) {
                 kim_error terr = KIM_NO_ERROR;
                 kim_count new_count = io_favorites->count - 1;
                 
+                found = 1;
+                
                 memmove (&io_favorites->identities[i], 
                          &io_favorites->identities[i + 1],
                          (new_count - i) * sizeof (*io_favorites->identities));