summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2008-05-06 17:39:44 +0200
committerSebastien Helleu <flashcode@flashtux.org>2008-05-06 17:39:44 +0200
commit6d37f185c09c9ec8fe21862d9f214c5747a64654 (patch)
tree33b650060633779734bf3b0699081441732fa04e
parent72721d7205e5724178c0e6ff29f32edfcccc8823 (diff)
downloadweechat-6d37f185c09c9ec8fe21862d9f214c5747a64654.zip
Fix crash after closing channels/pv (internal channel structure was not deleted) (bug #23178)
-rw-r--r--src/plugins/irc/irc-buffer.c13
-rw-r--r--src/plugins/irc/irc-channel.c72
-rw-r--r--src/plugins/irc/irc-channel.h6
-rw-r--r--src/plugins/irc/irc-command.c9
-rw-r--r--src/plugins/irc/irc-completion.c6
-rw-r--r--src/plugins/irc/irc-input.c26
-rw-r--r--src/plugins/irc/irc-protocol.c11
7 files changed, 20 insertions, 123 deletions
diff --git a/src/plugins/irc/irc-buffer.c b/src/plugins/irc/irc-buffer.c
index a31850b9c..3a6c0f97a 100644
--- a/src/plugins/irc/irc-buffer.c
+++ b/src/plugins/irc/irc-buffer.c
@@ -164,6 +164,8 @@ irc_buffer_split_server (t_gui_window *window)
int
irc_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
{
+ struct t_irc_channel *next_channel;
+
IRC_GET_SERVER_CHANNEL(buffer);
/* make C compiler happy */
@@ -176,19 +178,20 @@ irc_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
&& (ptr_channel->nicks))
{
irc_command_part_channel (ptr_server, ptr_channel->name, NULL);
- irc_channel_free (ptr_server, ptr_channel);
}
+ irc_channel_free (ptr_server, ptr_channel);
}
else
{
if (ptr_server)
{
/* send PART on all channels for server, then disconnect from server */
- for (ptr_channel = ptr_server->channels; ptr_channel;
- ptr_channel = ptr_channel->next_channel)
+ ptr_channel = ptr_server->channels;
+ while (ptr_channel)
{
- irc_command_part_channel (ptr_server, ptr_channel->name, NULL);
- irc_channel_free (ptr_server, ptr_channel);
+ next_channel = ptr_channel->next_channel;
+ weechat_buffer_close (ptr_channel->buffer, 1);
+ ptr_channel = next_channel;
}
irc_server_disconnect (ptr_server, 0);
ptr_server->buffer = NULL;
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index 1102dca95..48c63bcbc 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -84,7 +84,6 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
/* initialize new channel */
new_channel->type = channel_type;
- new_channel->dcc_chat = NULL;
new_channel->name = strdup (channel_name);
new_channel->topic = NULL;
new_channel->modes = NULL;
@@ -94,7 +93,6 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
new_channel->checking_away = 0;
new_channel->away_message = NULL;
new_channel->cycle = 0;
- new_channel->close = 0;
new_channel->display_creation_date = 0;
new_channel->nick_completion_reset = 0;
new_channel->nicks = NULL;
@@ -131,18 +129,6 @@ irc_channel_free (struct t_irc_server *server, struct t_irc_channel *channel)
if (!server || !channel)
return;
- /* close DCC CHAT */
- if (channel->dcc_chat)
- {
- channel->dcc_chat->channel = NULL;
- /*if (!IRC_DCC_ENDED(channel->dcc_chat->status))
- {
- irc_dcc_close (channel->dcc_chat, IRC_DCC_ABORTED);
- irc_dcc_redraw (1);
- }
- */
- }
-
/* remove channel from channels list */
if (server->last_channel == channel)
server->last_channel = channel->prev_channel;
@@ -191,7 +177,6 @@ irc_channel_free_all (struct t_irc_server *server)
/*
* irc_channel_search: returns pointer on a channel with name
- * WARNING: DCC chat channels are not returned by this function
*/
struct t_irc_channel *
@@ -205,8 +190,7 @@ irc_channel_search (struct t_irc_server *server, char *channel_name)
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
- if ((ptr_channel->type != IRC_CHANNEL_TYPE_DCC_CHAT)
- && (weechat_strcasecmp (ptr_channel->name, channel_name) == 0))
+ if (weechat_strcasecmp (ptr_channel->name, channel_name) == 0)
return ptr_channel;
}
return NULL;
@@ -258,28 +242,6 @@ irc_channel_search_any_without_buffer (struct t_irc_server *server,
}
/*
- * irc_channel_search_dcc: returns pointer on a DCC chat channel with name
- */
-
-struct t_irc_channel *
-irc_channel_search_dcc (struct t_irc_server *server, char *channel_name)
-{
- struct t_irc_channel *ptr_channel;
-
- if (!server || !channel_name)
- return NULL;
-
- for (ptr_channel = server->channels; ptr_channel;
- ptr_channel = ptr_channel->next_channel)
- {
- if ((ptr_channel->type == IRC_CHANNEL_TYPE_DCC_CHAT)
- && (weechat_strcasecmp (ptr_channel->name, channel_name) == 0))
- return ptr_channel;
- }
- return NULL;
-}
-
-/*
* irc_channel_is_channel: returns 1 if string is channel
*/
@@ -359,36 +321,6 @@ irc_channel_set_away (struct t_irc_channel *channel, char *nick, int is_away)
}
/*
- * irc_channel_create_dcc: create DCC CHAT channel
- */
-
-int
-irc_channel_create_dcc (struct t_irc_dcc *dcc)
-{
- struct t_irc_channel *ptr_channel;
-
- ptr_channel = irc_channel_search_dcc (dcc->server, dcc->nick);
- if (!ptr_channel)
- {
- ptr_channel = irc_channel_new (dcc->server,
- IRC_CHANNEL_TYPE_DCC_CHAT,
- dcc->nick,
- 0);
- if (!ptr_channel)
- return 0;
- }
-
- if (ptr_channel->dcc_chat &&
- (!IRC_DCC_ENDED(ptr_channel->dcc_chat->status)))
- return 0;
-
- ptr_channel->dcc_chat = dcc;
- dcc->channel = ptr_channel;
- //gui_window_redraw_buffer (ptr_channel->buffer);
- return 1;
-}
-
-/*
* irc_channel_get_notify_level: get channel notify level
*/
@@ -499,7 +431,6 @@ irc_channel_print_log (struct t_irc_channel *channel)
weechat_log_printf ("");
weechat_log_printf (" => channel %s (addr:0x%x)]", channel->name, channel);
weechat_log_printf (" type . . . . . . . . : %d", channel->type);
- weechat_log_printf (" dcc_chat . . . . . . : 0x%x", channel->dcc_chat);
weechat_log_printf (" topic. . . . . . . . : '%s'", channel->topic);
weechat_log_printf (" modes. . . . . . . . : '%s'", channel->modes);
weechat_log_printf (" limit. . . . . . . . : %d", channel->limit);
@@ -507,7 +438,6 @@ irc_channel_print_log (struct t_irc_channel *channel)
weechat_log_printf (" checking_away. . . . : %d", channel->checking_away);
weechat_log_printf (" away_message . . . . : '%s'", channel->away_message);
weechat_log_printf (" cycle. . . . . . . . : %d", channel->cycle);
- weechat_log_printf (" close. . . . . . . . : %d", channel->close);
weechat_log_printf (" display_creation_date: %d", channel->display_creation_date);
weechat_log_printf (" nicks. . . . . . . . : 0x%x", channel->nicks);
weechat_log_printf (" last_nick. . . . . . : 0x%x", channel->last_nick);
diff --git a/src/plugins/irc/irc-channel.h b/src/plugins/irc/irc-channel.h
index ff3b64344..ca335639e 100644
--- a/src/plugins/irc/irc-channel.h
+++ b/src/plugins/irc/irc-channel.h
@@ -26,7 +26,6 @@
#define IRC_CHANNEL_TYPE_UNKNOWN -1
#define IRC_CHANNEL_TYPE_CHANNEL 0
#define IRC_CHANNEL_TYPE_PRIVATE 1
-#define IRC_CHANNEL_TYPE_DCC_CHAT 2
#define IRC_CHANNEL_NICKS_SPEAKING_LIMIT 32
@@ -35,7 +34,6 @@ struct t_irc_server;
struct t_irc_channel
{
int type; /* channel type */
- struct t_irc_dcc *dcc_chat; /* DCC CHAT pointer (NULL if not DCC)*/
char *name; /* name of channel (exemple: "#abc") */
char *topic; /* topic of channel (host for pv) */
char *modes; /* channel modes */
@@ -45,7 +43,6 @@ struct t_irc_channel
int checking_away; /* = 1 if checking away with WHO cmd */
char *away_message; /* to display away only once in pv */
int cycle; /* currently cycling (/part + /join) */
- int close; /* close request (/buffer close) */
int display_creation_date; /* 1 for displaying creation date */
int nick_completion_reset; /* 1 for resetting nick completion */
/* there was some join/part on chan */
@@ -70,15 +67,12 @@ extern struct t_irc_channel *irc_channel_search_any (struct t_irc_server *server
char *channel_name);
extern struct t_irc_channel *irc_channel_search_any_without_buffer (struct t_irc_server *server,
char *channel_name);
-extern struct t_irc_channel *irc_channel_search_dcc (struct t_irc_server *server,
- char *channel_name);
extern int irc_channel_is_channel (char *string);
extern void irc_channel_remove_away (struct t_irc_channel *channel);
extern void irc_channel_check_away (struct t_irc_server *server,
struct t_irc_channel *channel, int force);
extern void irc_channel_set_away (struct t_irc_channel *channel, char *nick,
int is_away);
-extern int irc_channel_create_dcc (struct t_irc_dcc *dcc);
extern int irc_channel_get_notify_level (struct t_irc_server *server,
struct t_irc_channel *channel);
extern void irc_channel_set_notify_level (struct t_irc_server *server,
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index 0741dc51c..dbb6d1644 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -2210,8 +2210,6 @@ irc_command_part (void *data, struct t_gui_buffer *buffer, int argc,
if (!ptr_channel->nicks)
{
weechat_buffer_close (ptr_channel->buffer, 1);
- ptr_channel->buffer = NULL;
- irc_channel_free (ptr_server, ptr_channel);
return WEECHAT_RC_OK;
}
channel_name = ptr_channel->name;
@@ -3512,11 +3510,14 @@ irc_command_whois (void *data, struct t_gui_buffer *buffer, int argc,
else
{
if (ptr_channel
- && ((ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)
- || (ptr_channel->type == IRC_CHANNEL_TYPE_DCC_CHAT)))
+ && (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE))
+ {
irc_server_sendf (ptr_server, "WHOIS %s", ptr_channel->name);
+ }
else
+ {
IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "whois");
+ }
}
return WEECHAT_RC_OK;
diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c
index 81fe87aae..392ee7871 100644
--- a/src/plugins/irc/irc-completion.c
+++ b/src/plugins/irc/irc-completion.c
@@ -189,8 +189,7 @@ irc_completion_channel_nicks_cb (void *data, char *completion,
/* add self nick at the end */
weechat_list_add (list, ptr_server->nick, WEECHAT_LIST_POS_END);
}
- if ((ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)
- || (ptr_channel->type == IRC_CHANNEL_TYPE_DCC_CHAT))
+ if (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)
{
weechat_list_add (list, ptr_channel->name, WEECHAT_LIST_POS_SORT);
}
@@ -244,8 +243,7 @@ irc_completion_channel_nicks_hosts_cb (void *data, char *completion,
}
}
}
- if ((ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)
- || (ptr_channel->type == IRC_CHANNEL_TYPE_DCC_CHAT))
+ if (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)
{
weechat_list_add (list, ptr_channel->name,
WEECHAT_LIST_POS_SORT);
diff --git a/src/plugins/irc/irc-input.c b/src/plugins/irc/irc-input.c
index 1a6c86598..03e7d9147 100644
--- a/src/plugins/irc/irc-input.c
+++ b/src/plugins/irc/irc-input.c
@@ -49,8 +49,7 @@ irc_input_user_message_display (struct t_gui_buffer *buffer, char *text)
if (ptr_channel)
{
- if ((ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)
- || (ptr_channel->type == IRC_CHANNEL_TYPE_DCC_CHAT))
+ if (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)
{
weechat_printf (buffer,
"%s%s",
@@ -167,27 +166,8 @@ irc_input_data_cb (void *data, struct t_gui_buffer *buffer, char *input_data)
data_with_colors = irc_color_encode (input_data,
weechat_config_boolean (irc_config_network_colors_send));
- if (ptr_channel->dcc_chat)
- {
- if (ptr_channel->dcc_chat->sock < 0)
- {
- weechat_printf (buffer,
- "%s%s: DCC CHAT is closed",
- weechat_prefix ("error"), "irc");
- }
- else
- {
- //irc_dcc_chat_sendf (ptr_channel->dcc_chat,
- // "%s\r\n",
- // (data_with_colors) ? data_with_colors : input_data);
- //irc_input_user_message_display (buffer,
- // (data_with_colors) ?
- // data_with_colors : input_data);
- }
- }
- else
- irc_input_send_user_message (buffer,
- (data_with_colors) ? data_with_colors : input_data);
+ irc_input_send_user_message (buffer,
+ (data_with_colors) ? data_with_colors : input_data);
if (data_with_colors)
free (data_with_colors);
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index b945f3fbc..82657b11d 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -794,7 +794,6 @@ irc_protocol_cmd_nick (struct t_irc_server *server, char *command,
switch (ptr_channel->type)
{
case IRC_CHANNEL_TYPE_PRIVATE:
- case IRC_CHANNEL_TYPE_DCC_CHAT:
/* rename private window if this is with "old nick" */
if (weechat_strcasecmp (ptr_channel->name, old_nick) == 0)
{
@@ -1178,13 +1177,6 @@ irc_protocol_cmd_part (struct t_irc_server *server, char *command,
else
irc_command_join_server (server, ptr_channel->name);
}
- if (ptr_channel->close)
- {
- weechat_buffer_close (ptr_channel->buffer, 1);
- ptr_channel->buffer = NULL;
- irc_channel_free (server, ptr_channel);
- ptr_channel = NULL;
- }
}
else
irc_nick_free (ptr_channel, ptr_nick);
@@ -2293,8 +2285,7 @@ irc_protocol_cmd_quit (struct t_irc_server *server, char *command,
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
- if ((ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)
- || (ptr_channel->type == IRC_CHANNEL_TYPE_DCC_CHAT))
+ if (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)
ptr_nick = NULL;
else
ptr_nick = irc_nick_search (ptr_channel, nick);