39 lines
1.3 KiB
Diff
39 lines
1.3 KiB
Diff
# UNDF: UNDF-2026-000001141
|
|
# UNDF:
|
|
--- a/libpurple/privacy.c
|
|
+++ b/libpurple/privacy.c
|
|
@@ -231,18 +231,24 @@ static void
|
|
add_all_buddies_to_permit_list(PurpleAccount *account, gboolean local)
|
|
{
|
|
GSList *list;
|
|
+ GHashTable *permit_set;
|
|
+ GSList *permit_iter;
|
|
|
|
/* Remove anyone in the permit list who is not in the buddylist */
|
|
for (list = account->permit; list != NULL; ) {
|
|
char *person = list->data;
|
|
list = list->next;
|
|
if (!purple_find_buddy(account, person))
|
|
purple_privacy_permit_remove(account, person, local);
|
|
}
|
|
|
|
+ /* Build a hash set of existing permit names for O(1) membership test */
|
|
+ permit_set = g_hash_table_new(g_str_hash, g_str_equal);
|
|
+ for (permit_iter = account->permit; permit_iter != NULL; permit_iter = permit_iter->next)
|
|
+ g_hash_table_add(permit_set, permit_iter->data);
|
|
+
|
|
/* Now make sure everyone in the buddylist is in the permit list */
|
|
list = purple_find_buddies(account, NULL);
|
|
while (list != NULL)
|
|
{
|
|
PurpleBuddy *buddy = list->data;
|
|
const gchar *name = purple_buddy_get_name(buddy);
|
|
|
|
- if (!g_slist_find_custom(account->permit, name, (GCompareFunc)g_utf8_collate))
|
|
+ if (!g_hash_table_lookup(permit_set, name))
|
|
purple_privacy_permit_add(account, name, local);
|
|
list = g_slist_delete_link(list, list);
|
|
}
|
|
+
|
|
+ g_hash_table_destroy(permit_set);
|
|
}
|