aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/jabber/jabber_util.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2009-11-19 14:58:30 +0000
committerWilmer van der Gaast <wilmer@gaast.net>2009-11-19 14:58:30 +0000
commit20e830b641638bc580e1a58b68fc3c5837e76807 (patch)
tree1a4c4ea448cf170af9bd702a26398ead75d0b420 /protocols/jabber/jabber_util.c
parent76c85b4c79d533ca7a780df381ccda5b9ab2934c (diff)
Fixed a facepalm kind of NULL pointer dereference bug.
Diffstat (limited to 'protocols/jabber/jabber_util.c')
-rw-r--r--protocols/jabber/jabber_util.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c
index 6c37c2ef..ec23919e 100644
--- a/protocols/jabber/jabber_util.c
+++ b/protocols/jabber/jabber_util.c
@@ -462,7 +462,7 @@ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_,
char *set;
head = g_hash_table_lookup( jd->buddies, jid );
- bud = head->next ? head->next : head;
+ bud = ( head && head->next ) ? head->next : head;
g_free( jid );
@@ -545,7 +545,7 @@ struct jabber_buddy *jabber_buddy_by_ext_jid( struct im_connection *ic, char *ji
int jabber_buddy_remove( struct im_connection *ic, char *full_jid_ )
{
struct jabber_data *jd = ic->proto_data;
- struct jabber_buddy *head, *bud, *prev, *bi;
+ struct jabber_buddy *bud, *prev, *bi;
char *s, *full_jid;
full_jid = jabber_normalize( full_jid_ );
@@ -553,9 +553,10 @@ int jabber_buddy_remove( struct im_connection *ic, char *full_jid_ )
if( ( s = strchr( full_jid, '/' ) ) )
*s = 0;
- if( ( head = g_hash_table_lookup( jd->buddies, full_jid ) ) )
+ if( ( bud = g_hash_table_lookup( jd->buddies, full_jid ) ) )
{
- bud = head->next ? head->next : head;
+ if( bud->next )
+ bud = bud->next;
/* If there's only one item in the list (and if the resource
matches), removing it is simple. (And the hash reference