Fix segfault by canceling pending login timer on close

This commit is contained in:
mjentsch 2015-01-22 21:28:13 +01:00
parent 3f70192cd3
commit 1dd7be0262
3 changed files with 9 additions and 3 deletions

View file

@ -518,7 +518,9 @@ static int all_authorized (struct tgl_state *TLS) {
static int check_all_authorized (gpointer arg) {
struct tgl_state *TLS = arg;
if (all_authorized (TLS)) {
((connection_data *)TLS->ev_base)->login_timer = 0;
telegram_send_sms (TLS);
return FALSE;
} else {
@ -526,7 +528,9 @@ static int check_all_authorized (gpointer arg) {
}
}
void telegram_login (struct tgl_state *TLS) {
void telegram_login (struct tgl_state *TLS) {
connection_data *conn = TLS->ev_base;
read_auth_file (TLS);
read_state_file (TLS);
read_secret_chat_file (TLS);
@ -534,7 +538,7 @@ void telegram_login (struct tgl_state *TLS) {
telegram_send_sms (TLS);
return;
}
purple_timeout_add (100, check_all_authorized, TLS);
conn->login_timer = purple_timeout_add (100, check_all_authorized, TLS);
}
PurpleConversation *chat_show (PurpleConnection *gc, int id) {

View file

@ -111,7 +111,8 @@ connection_data *connection_data_init (struct tgl_state *TLS, PurpleConnection *
void *connection_data_free (connection_data *conn)
{
purple_timeout_remove(conn->timer);
purple_timeout_remove (conn->timer);
if (conn->login_timer) { purple_timeout_remove(conn->login_timer); }
tgp_g_queue_free_full (conn->pending_reads, pending_reads_free_cb);
tgp_g_queue_free_full (conn->new_messages, message_text_free);
g_hash_table_destroy (conn->joining_chats);

View file

@ -37,6 +37,7 @@ typedef struct {
GList *used_images;
GHashTable *joining_chats;
guint timer;
guint login_timer;
int in_fallback_chat;
} connection_data;