diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2022-01-26 20:22:56 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2022-01-26 20:22:56 +0100 |
commit | 0ebf3dbede0334e541f9c2e115267a69d2b063dc (patch) | |
tree | 1e34d893ccfd25ecc34007b7d9db4c722c24bd44 /src | |
parent | 13fb3649dd8bd1d51513ff53ac2b7c35f0058954 (diff) | |
download | weechat-0ebf3dbede0334e541f9c2e115267a69d2b063dc.zip |
core: fix memory leak when removing a line on a buffer with free content
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/gui-chat.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index cf42e7cb9..7620a6344 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -1092,28 +1092,33 @@ gui_chat_printf_y (struct t_gui_buffer *buffer, int y, const char *message, ...) free (new_line); } } - else if (gui_init_ok) + else { - /* delete line */ - last_y = (new_line->data->buffer->own_lines->last_line) ? - new_line->data->buffer->own_lines->last_line->data->y : 0; - if (y <= last_y) + if (gui_init_ok) { - for (ptr_line = new_line->data->buffer->own_lines->first_line; - ptr_line; ptr_line = ptr_line->next_line) - { - if (ptr_line->data->y >= y) - break; - } - if (ptr_line && (ptr_line->data->y == y)) + /* delete line */ + last_y = (new_line->data->buffer->own_lines->last_line) ? + new_line->data->buffer->own_lines->last_line->data->y : 0; + if (y <= last_y) { - if (ptr_line->next_line) - gui_line_clear (ptr_line); - else - gui_line_free (new_line->data->buffer, ptr_line); - gui_buffer_ask_chat_refresh (new_line->data->buffer, 2); + for (ptr_line = new_line->data->buffer->own_lines->first_line; + ptr_line; ptr_line = ptr_line->next_line) + { + if (ptr_line->data->y >= y) + break; + } + if (ptr_line && (ptr_line->data->y == y)) + { + if (ptr_line->next_line) + gui_line_clear (ptr_line); + else + gui_line_free (new_line->data->buffer, ptr_line); + gui_buffer_ask_chat_refresh (new_line->data->buffer, 2); + } } } + gui_line_free_data (new_line); + free (new_line); } end: |