1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

relay: fix crash when closing relay buffers (closes #57, closes #78)

A flag "closing" has been added in buffers. It is set to 1 when the buffer
is closing, and then no more printf is allowed in the buffer (a message
printed on relay buffer was causing a crash when it is closed).
This commit is contained in:
Sébastien Helleu
2014-05-24 18:57:29 +02:00
parent faae8f470b
commit 02eed97d97
4 changed files with 28 additions and 11 deletions
+1
View File
@@ -139,6 +139,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
* lua: fix interpreter used after unload of a script
* perl: fix context used after unload of a script
* python: fix interpreter used after unload of a script
* relay: fix crash when closing relay buffers (closes #57, closes #78)
* relay: check pointers received in hdata command to prevent crashes with bad
pointers (WeeChat protocol)
* relay: remove warning on /reload of relay.conf when ports are defined
+17 -8
View File
@@ -78,14 +78,14 @@ char *gui_buffer_notify_string[GUI_BUFFER_NUM_NOTIFY] =
char *gui_buffer_properties_get_integer[] =
{ "number", "layout_number", "layout_number_merge_order", "type", "notify",
"num_displayed", "active", "hidden", "zoomed", "print_hooks_enabled",
"day_change", "clear", "filter", "lines_hidden", "prefix_max_length",
"time_for_each_line", "nicklist", "nicklist_case_sensitive",
"nicklist_max_length", "nicklist_display_groups", "nicklist_count",
"nicklist_groups_count", "nicklist_nicks_count", "nicklist_visible_count",
"input", "input_get_unknown_commands", "input_size", "input_length",
"input_pos", "input_1st_display", "num_history", "text_search",
"text_search_exact", "text_search_regex", "text_search_where",
"text_search_found",
"day_change", "clear", "filter", "closing", "lines_hidden",
"prefix_max_length", "time_for_each_line", "nicklist",
"nicklist_case_sensitive", "nicklist_max_length", "nicklist_display_groups",
"nicklist_count", "nicklist_groups_count", "nicklist_nicks_count",
"nicklist_visible_count", "input", "input_get_unknown_commands",
"input_size", "input_length", "input_pos", "input_1st_display",
"num_history", "text_search", "text_search_exact", "text_search_regex",
"text_search_where", "text_search_found",
NULL
};
char *gui_buffer_properties_get_string[] =
@@ -603,6 +603,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
/* close callback */
new_buffer->close_callback = close_callback;
new_buffer->close_callback_data = close_callback_data;
new_buffer->closing = 0;
/* title */
new_buffer->title = NULL;
@@ -995,6 +996,8 @@ gui_buffer_get_integer (struct t_gui_buffer *buffer, const char *property)
return buffer->clear;
else if (string_strcasecmp (property, "filter") == 0)
return buffer->filter;
else if (string_strcasecmp (property, "closing") == 0)
return buffer->closing;
else if (string_strcasecmp (property, "lines_hidden") == 0)
return buffer->lines->lines_hidden;
else if (string_strcasecmp (property, "prefix_max_length") == 0)
@@ -2515,6 +2518,8 @@ gui_buffer_close (struct t_gui_buffer *buffer)
int index, i;
struct t_gui_buffer_visited *ptr_buffer_visited;
buffer->closing = 1;
(void) hook_signal_send ("buffer_closing",
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
@@ -3964,6 +3969,7 @@ gui_buffer_hdata_buffer_cb (void *data, const char *hdata_name)
HDATA_VAR(struct t_gui_buffer, filter, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, close_callback, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, close_callback_data, POINTER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, closing, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, title, STRING, 0, NULL, NULL);
HDATA_VAR(struct t_gui_buffer, own_lines, POINTER, 0, NULL, "lines");
HDATA_VAR(struct t_gui_buffer, mixed_lines, POINTER, 0, NULL, "lines");
@@ -4146,6 +4152,8 @@ gui_buffer_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!infolist_new_var_integer (ptr_item, "filter", buffer->filter))
return 0;
if (!infolist_new_var_integer (ptr_item, "closing", buffer->closing))
return 0;
if (!infolist_new_var_integer (ptr_item, "first_line_not_read", buffer->lines->first_line_not_read))
return 0;
if (!infolist_new_var_integer (ptr_item, "lines_hidden", buffer->lines->lines_hidden))
@@ -4358,6 +4366,7 @@ gui_buffer_print_log ()
log_printf (" filter. . . . . . . . . : %d", ptr_buffer->filter);
log_printf (" close_callback. . . . . : 0x%lx", ptr_buffer->close_callback);
log_printf (" close_callback_data . . : 0x%lx", ptr_buffer->close_callback_data);
log_printf (" closing . . . . . . . . : %d", ptr_buffer->closing);
log_printf (" title . . . . . . . . . : '%s'", ptr_buffer->title);
log_printf (" own_lines . . . . . . . : 0x%lx", ptr_buffer->own_lines);
gui_lines_print_log (ptr_buffer->own_lines);
+1
View File
@@ -109,6 +109,7 @@ struct t_gui_buffer
int (*close_callback)(void *data, /* called when buffer is closed */
struct t_gui_buffer *buffer);
void *close_callback_data; /* data for callback */
int closing; /* 1 if the buffer is being closed */
/* buffer title */
char *title; /* buffer title */
+9 -3
View File
@@ -644,10 +644,10 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
char *modifier_data, *new_msg, *ptr_msg, *lines_waiting;
struct t_gui_line *ptr_line;
if (!gui_buffer_valid (buffer))
if (!message)
return;
if (!message)
if (!gui_buffer_valid (buffer))
return;
if (gui_init_ok)
@@ -655,7 +655,7 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
if (!buffer)
buffer = gui_buffer_search_main ();
if (!buffer)
if (!buffer || buffer->closing)
return;
if (buffer->type != GUI_BUFFER_TYPE_FORMATTED)
@@ -842,11 +842,17 @@ gui_chat_printf_y (struct t_gui_buffer *buffer, int y, const char *message, ...)
struct t_gui_line *ptr_line;
int i, num_lines_to_add;
if (!gui_buffer_valid (buffer))
return;
if (gui_init_ok)
{
if (!buffer)
buffer = gui_buffer_search_main ();
if (!buffer || buffer->closing)
return;
if (buffer->type != GUI_BUFFER_TYPE_FREE)
buffer = gui_buffers;