From: <nos...@us...> - 2006-10-26 15:55:40
|
Revision: 17588 http://svn.sourceforge.net/gaim/?rev=17588&view=rev Author: nosnilmot Date: 2006-10-26 08:55:31 -0700 (Thu, 26 Oct 2006) Log Message: ----------- Don't rely on the sender or receiver of messages being a buddy, and add some other safeguards to prevent crashes like bug #1585017 I'm pretty sure this is good, but don't have the necessary sqlite installed to test this at the moment. Modified Paths: -------------- trunk/gtk/plugins/cap/cap.c Modified: trunk/gtk/plugins/cap/cap.c =================================================================== --- trunk/gtk/plugins/cap/cap.c 2006-10-26 06:20:18 UTC (rev 17587) +++ trunk/gtk/plugins/cap/cap.c 2006-10-26 15:55:31 UTC (rev 17588) @@ -109,6 +109,9 @@ static CapStatistics * get_stats_for(GaimBuddy *buddy) { gchar *buddy_name; CapStatistics *stats; + + g_return_val_if_fail(buddy != NULL, NULL); + buddy_name = g_strdup(buddy->name); stats = g_hash_table_lookup(_buddy_stats, buddy_name); if(!stats) { @@ -340,9 +343,17 @@ /* sent-im-msg */ static void sent_im_msg(GaimAccount *account, const char *receiver, const char *message) { - GaimBuddy *buddy = gaim_find_buddy(account, receiver); - guint interval = gaim_prefs_get_int("/plugins/gtk/cap/max_msg_difference") * 1000 * 60; - guint words = word_count(message); + GaimBuddy *buddy; + guint interval, words; + + buddy = gaim_find_buddy(account, receiver); + + if (buddy == NULL) + return; + + interval = gaim_prefs_get_int("/plugins/gtk/cap/max_msg_difference") * 1000 * 60; + words = word_count(message); + CapStatistics *stats = get_stats_for(buddy); insert_word_count(gaim_account_get_username(account), receiver, words); @@ -357,10 +368,17 @@ /* received-im-msg */ static void received_im_msg(GaimAccount *account, char *sender, char *message, GaimConversation *conv, GaimMessageFlags flags) { - GaimBuddy *buddy = gaim_find_buddy(account, sender); + GaimBuddy *buddy; + CapStatistics *stats; /* guint words = word_count(message); */ - CapStatistics *stats = get_stats_for(buddy); + buddy = gaim_find_buddy(account, sender); + + if (buddy == NULL) + return; + + stats = get_stats_for(buddy); + /* insert_word_count(sender, buddy_name, words); */ /* If we are waiting for a response from a prior message This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |