Skip to content

Commit

Permalink
Fix memleak and corruption
Browse files Browse the repository at this point in the history
  • Loading branch information
EionRobb committed Apr 8, 2020
1 parent 9203458 commit 7f61c84
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions slack-message.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ void slack_handle_message(SlackAccount *sa, SlackObject *obj, json_value *json,

static void handle_message(SlackAccount *sa, gpointer data, SlackObject *obj) {
json_value *json = data;
return slack_handle_message(sa, obj, json, PURPLE_MESSAGE_RECV);
slack_handle_message(sa, obj, json, PURPLE_MESSAGE_RECV);
json_value_free(json);
}

Expand All @@ -500,6 +500,7 @@ static gboolean slack_unset_typing_cb(SlackChatBuddy *chatbuddy) {
}

g_free(chatbuddy->name);
chatbuddy->name = NULL;
return FALSE;
}

Expand All @@ -519,8 +520,8 @@ void slack_user_typing(SlackAccount *sa, json_value *json) {
if (cb) {
purple_conv_chat_user_set_flags(chat, user->object.name, cb->flags | PURPLE_CBFLAGS_TYPING);

guint timeout = GPOINTER_TO_INT(g_dataset_get_data(cb, "typing_timeout"));
SlackChatBuddy *chatbuddy = g_dataset_get_data(cb, "chatbuddy");
guint timeout = GPOINTER_TO_UINT(g_dataset_get_data(user, "typing_timeout"));
SlackChatBuddy *chatbuddy = g_dataset_get_data(user, "chatbuddy");
if (timeout) {
purple_timeout_remove(timeout);
if (chatbuddy) {
Expand All @@ -533,8 +534,8 @@ void slack_user_typing(SlackAccount *sa, json_value *json) {
chatbuddy->name = g_strdup(user->object.name);
timeout = purple_timeout_add_seconds(4, (GSourceFunc)slack_unset_typing_cb, chatbuddy);

g_dataset_set_data(cb, "typing_timeout", GINT_TO_POINTER(timeout));
g_dataset_set_data(cb, "chatbuddy", chatbuddy);
g_dataset_set_data(user, "typing_timeout", GUINT_TO_POINTER(timeout));
g_dataset_set_data(user, "chatbuddy", chatbuddy);
}
} else {
purple_debug_warning("slack", "Unhandled typing: %s@%s\n", user_id, channel_id);
Expand Down

4 comments on commit 7f61c84

@zoltan-dulac
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering, is this due to a current issue that happens often? I have been experiencing issues with Pidgin for the last few days (it crashes after about a half an hour to an hour) and just wondering if it's because of this (not saying it's this plugin ... I am still trying to figure out why it is happening). Any info would be great! :-)

@EionRobb
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I corrupted some memory when adding the group typing notification support
One of the memleaks was already there though (the early return in handle-message) and caused Pidgin to run out of memory and crash on windows after 24hrs

@EionRobb
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zoltan-dulac if your backtrace doesn't say much other than ssl-nss, you might be experiencing a crash that's resolved in the discord prpl. Try updating that if you're using it

@zoltan-dulac
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @EionRobb ! That's probably it. Will look into that. Thanks for the tip! Really appreciate it.

Please sign in to comment.