From: Alexandra Ellwood Date: Thu, 25 Sep 2008 20:25:40 +0000 (+0000) Subject: Fixed a bug where kim_preferences_remove_favorite_identity X-Git-Tag: krb5-1.7-alpha1~418 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2566cc858ade894e695872c346b97c53c97177ea;p=krb5.git Fixed a bug where kim_preferences_remove_favorite_identity 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 --- diff --git a/src/kim/lib/kim_preferences.c b/src/kim/lib/kim_preferences.c index 8ec5fd16c..46600922f 100644 --- a/src/kim/lib/kim_preferences.c +++ b/src/kim/lib/kim_preferences.c @@ -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));