From: <aar...@us...> - 2006-07-20 12:53:57
|
Revision: 16527 Author: aaronsheldon Date: 2006-07-20 05:53:46 -0700 (Thu, 20 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16527&view=rev Log Message: ----------- Sadrul sent me this patch to look over and then commit. It fixes a PRPL leak in Yahoo's chat and fixes a few other memory leaks that were mostly my fault. Modified Paths: -------------- trunk/src/conversation.c trunk/src/gtkconv.c trunk/src/protocols/yahoo/yahoochat.c Modified: trunk/src/conversation.c =================================================================== --- trunk/src/conversation.c 2006-07-20 08:12:17 UTC (rev 16526) +++ trunk/src/conversation.c 2006-07-20 12:53:46 UTC (rev 16527) @@ -1485,7 +1485,7 @@ { GaimConversation *conv; GaimConversationUiOps *ops; - GaimConvChatBuddy *cb; + GaimConvChatBuddy *cbuddy; GaimConnection *gc; GaimPluginProtocolInfo *prpl_info; GList *ul, *fl; @@ -1508,12 +1508,9 @@ const char *user = (const char *)ul->data; const char *alias = user; gboolean quiet; - GaimConvChatBuddy *cbuddy; - GaimConvChatBuddyFlags flags = GPOINTER_TO_INT(fl->data); + GaimConvChatBuddyFlags flag = GPOINTER_TO_INT(fl->data); const char *extra_msg = (extra_msgs ? extra_msgs->data : NULL); - cbuddy = gaim_conv_chat_cb_new(user, NULL, GPOINTER_TO_INT(fl->data)); - if (!strcmp(chat->nick, gaim_normalize(conv->account, user))) { const char *alias2 = gaim_account_get_alias(conv->account); if (alias2 != NULL) @@ -1531,17 +1528,14 @@ } quiet = GPOINTER_TO_INT(gaim_signal_emit_return_1(gaim_conversations_get_handle(), - "chat-buddy-joining", conv, user, flags)) | + "chat-buddy-joining", conv, user, flag)) | gaim_conv_chat_is_user_ignored(chat, user); - cb = gaim_conv_chat_cb_new(user, NULL, flags); + cbuddy = gaim_conv_chat_cb_new(user, alias, flag); /* This seems dumb. Why should we set users thousands of times? */ gaim_conv_chat_set_users(chat, - g_list_prepend(gaim_conv_chat_get_users(chat), cb)); + g_list_prepend(gaim_conv_chat_get_users(chat), cbuddy)); - cbuddy->alias = strdup(alias); /* Should I be doing a strdup? */ - cbuddy->alias_key = g_utf8_collate_key(alias, strlen(alias)); - cbuddy->buddy = (gaim_find_buddy(conv->account, cbuddy->name) != NULL); cbuddies = g_list_prepend(cbuddies, cbuddy); if (!quiet && new_arrivals) { @@ -1563,7 +1557,7 @@ } gaim_signal_emit(gaim_conversations_get_handle(), - "chat-buddy-joined", conv, user, flags, new_arrivals); + "chat-buddy-joined", conv, user, flag, new_arrivals); ul = ul->next; fl = fl->next; if (extra_msgs != NULL) @@ -1575,6 +1569,7 @@ if (ops != NULL && ops->chat_add_users != NULL) ops->chat_add_users(conv, cbuddies, new_arrivals); + g_list_free(cbuddies); } void Modified: trunk/src/gtkconv.c =================================================================== --- trunk/src/gtkconv.c 2006-07-20 08:12:17 UTC (rev 16526) +++ trunk/src/gtkconv.c 2006-07-20 12:53:46 UTC (rev 16527) @@ -3398,6 +3398,7 @@ if (pixbuf) g_object_unref(pixbuf); + g_free(alias_key); } static void @@ -3707,7 +3708,7 @@ if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { const char *alias = name; - char *alias_key = g_utf8_collate_key(alias, strlen(alias)); + char *alias_key = NULL; GaimBuddy *buddy2; if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { @@ -3715,13 +3716,15 @@ if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) { alias = gaim_buddy_get_contact_alias(buddy2); - alias_key = g_utf8_collate_key(alias, strlen(alias)); } + alias_key = g_utf8_collate_key(alias, strlen(alias)); + gtk_list_store_set(GTK_LIST_STORE(model), &iter, CHAT_USERS_ALIAS_COLUMN, alias, CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, -1); + g_free(alias_key); } g_free(name); break; Modified: trunk/src/protocols/yahoo/yahoochat.c =================================================================== --- trunk/src/protocols/yahoo/yahoochat.c 2006-07-20 08:12:17 UTC (rev 16526) +++ trunk/src/protocols/yahoo/yahoochat.c 2006-07-20 12:53:46 UTC (rev 16527) @@ -460,6 +460,7 @@ yd->chat_name = g_strdup(room); gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members, NULL, flags, FALSE); } + g_list_free(flags); } else if (c) { yahoo_chat_add_users(GAIM_CONV_CHAT(c), members); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |