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

core: fix memory leak when removing a line on a buffer with free content

This commit is contained in:
Sébastien Helleu
2022-01-26 20:22:56 +01:00
parent 13fb3649dd
commit 0ebf3dbede
2 changed files with 23 additions and 17 deletions
+1
View File
@@ -26,6 +26,7 @@ New features::
Bug fixes::
* core: fix memory leak when removing a line on a buffer with free content
* core: remove obsolete option weechat.plugin.debug (issue #1744)
* core: fix search of commands with UTF-8 chars in name when option weechat.look.command_incomplete is on (issue #1739)
* core: fix display of hotlist in buflist after changing value of option weechat.look.hotlist_sort (issue #1733)
+22 -17
View File
@@ -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)
/* 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->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);
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: