aboutsummaryrefslogtreecommitdiffstats
path: root/matrix-room.c
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2015-11-03 16:04:16 +0000
committerRichard van der Hoff <richard@matrix.org>2015-11-03 16:04:16 +0000
commit8ba9593fc0328402532cee46926ce6936f072294 (patch)
tree2ad258ee8d9f4ddefb74c6582303e2aedefeefd2 /matrix-room.c
parent6322cd5a34989100f7650e750aa3b5fca7904a35 (diff)
downloadpurple-matrix-8ba9593fc0328402532cee46926ce6936f072294.tar.gz
Fix infinite loop in matrix_room_displayname_to_userid
Double-clicking a user in the chat window would cause an infinite loop. Because apparently I fail at linked-lists.
Diffstat (limited to 'matrix-room.c')
-rw-r--r--matrix-room.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/matrix-room.c b/matrix-room.c
index 2d15942..1a8738f 100644
--- a/matrix-room.c
+++ b/matrix-room.c
@@ -728,21 +728,22 @@ gchar *matrix_room_displayname_to_userid(struct _PurpleConversation *conv,
{
/* TODO: make this more efficient */
MatrixRoomMemberTable *table = matrix_room_get_member_table(conv);
- GList *members;
+ GList *members, *ptr;
+ gchar *result = NULL;
members = matrix_roommembers_get_active_members(table, TRUE);
- while(members != NULL) {
- MatrixRoomMember *member = members->data;
+ for(ptr = members; ptr != NULL; ptr = ptr->next) {
+ MatrixRoomMember *member = ptr->data;
const gchar *displayname = matrix_roommember_get_opaque_data(member);
if(g_strcmp0(displayname, who) == 0) {
- g_list_free(members);
- return g_strdup(matrix_roommember_get_user_id(member));
+ result = g_strdup(matrix_roommember_get_user_id(member));
+ break;
}
}
g_list_free(members);
- return NULL;
+ return result;
}
/* ************************************************************************** */