Mercurial > hg
changeset 670:2cd0805515a4
Fix a bug in roster_find()
When doing a name-based search, roster_find() did not check type
correctly, which could lead to a segfault in some other places.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 15 Jan 2006 10:00:03 +0100 |
parents | 2b87065270f3 |
children | c5da36fd437a |
files | mcabber/src/roster.c |
diffstat | 1 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mcabber/src/roster.c Sat Jan 14 13:40:07 2006 +0100 +++ b/mcabber/src/roster.c Sun Jan 15 10:00:03 2006 +0100 @@ -207,6 +207,13 @@ return strcasecmp(a->jid, b->jid); } +// Comparison function used to search in the roster (compares names and types) +static gint roster_compare_name_type(roster *a, roster *b) { + if (! (a->type & b->type)) + return -1; // arbitrary (but should be != 0, of course) + return strcasecmp(a->name, b->name); +} + // Comparison function used to sort the roster (by name) static gint roster_compare_name(roster *a, roster *b) { return strcasecmp(a->name, b->name); @@ -234,7 +241,7 @@ comp = (GCompareFunc)&roster_compare_jid_type; } else if (type == namesearch) { sample.name = (gchar*)jidname; - comp = (GCompareFunc)&roster_compare_name; + comp = (GCompareFunc)&roster_compare_name_type; } else return NULL; // should not happen