mirror of
https://github.com/weechat/weechat.git
synced 2026-06-12 14:14:48 +02:00
Fix some memory leaks
This commit is contained in:
@@ -101,8 +101,14 @@ config_file_new (struct t_weechat_plugin *plugin, const char *name,
|
||||
new_config_file->name = strdup (name);
|
||||
length = strlen (name) + 8 + 1;
|
||||
filename = malloc (length);
|
||||
snprintf (filename, length, "%s.conf", name);
|
||||
new_config_file->filename = strdup (filename);
|
||||
if (filename)
|
||||
{
|
||||
snprintf (filename, length, "%s.conf", name);
|
||||
new_config_file->filename = strdup (filename);
|
||||
free (filename);
|
||||
}
|
||||
else
|
||||
new_config_file->filename = strdup (name);
|
||||
new_config_file->file = NULL;
|
||||
new_config_file->callback_reload = callback_reload;
|
||||
new_config_file->callback_reload_data = callback_reload_data;
|
||||
|
||||
@@ -1594,11 +1594,15 @@ unhook (struct t_hook *hook)
|
||||
case HOOK_TYPE_INFO:
|
||||
if (HOOK_INFO(hook, info_name))
|
||||
free (HOOK_INFO(hook, info_name));
|
||||
if (HOOK_INFO(hook, description))
|
||||
free (HOOK_INFO(hook, description));
|
||||
free ((struct t_hook_info *)hook->hook_data);
|
||||
break;
|
||||
case HOOK_TYPE_INFOLIST:
|
||||
if (HOOK_INFOLIST(hook, infolist_name))
|
||||
free (HOOK_INFOLIST(hook, infolist_name));
|
||||
if (HOOK_INFOLIST(hook, description))
|
||||
free (HOOK_INFOLIST(hook, description));
|
||||
free ((struct t_hook_infolist *)hook->hook_data);
|
||||
break;
|
||||
case HOOK_NUM_TYPES:
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "../gui-buffer.h"
|
||||
#include "../gui-chat.h"
|
||||
#include "../gui-color.h"
|
||||
#include "../gui-filter.h"
|
||||
#include "../gui-input.h"
|
||||
#include "../gui-history.h"
|
||||
#include "../gui-nicklist.h"
|
||||
@@ -334,18 +335,25 @@ gui_main_end (int clean_exit)
|
||||
gui_bar_item_end ();
|
||||
gui_bar_free_all ();
|
||||
|
||||
/* remove filters */
|
||||
gui_filter_free_all ();
|
||||
|
||||
/* free clipboard buffer */
|
||||
if (gui_input_clipboard)
|
||||
free (gui_input_clipboard);
|
||||
|
||||
/* delete all windows */
|
||||
while (gui_windows)
|
||||
{
|
||||
gui_window_free (gui_windows);
|
||||
}
|
||||
gui_window_tree_free (&gui_windows_tree);
|
||||
|
||||
/* delete all buffers */
|
||||
while (gui_buffers)
|
||||
{
|
||||
gui_buffer_close (gui_buffers, 0);
|
||||
}
|
||||
|
||||
/* delete global history */
|
||||
gui_history_global_free ();
|
||||
|
||||
@@ -33,9 +33,12 @@
|
||||
#include "../../core/wee-config.h"
|
||||
#include "../../core/wee-utf8.h"
|
||||
#include "../../plugins/plugin.h"
|
||||
#include "../gui-bar.h"
|
||||
#include "../gui-bar-item.h"
|
||||
#include "../gui-chat.h"
|
||||
#include "../gui-main.h"
|
||||
#include "../gui-buffer.h"
|
||||
#include "../gui/gui-filter.h"
|
||||
#include "../gui-history.h"
|
||||
#include "../gui-input.h"
|
||||
#include "../gui-window.h"
|
||||
@@ -207,28 +210,32 @@ gui_main_loop ()
|
||||
void
|
||||
gui_main_end (int clean_exit)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
if (clean_exit)
|
||||
{
|
||||
/* remove bar items and bars */
|
||||
gui_bar_item_end ();
|
||||
gui_bar_free_all ();
|
||||
|
||||
/* remove filters */
|
||||
gui_filter_free_all ();
|
||||
|
||||
/* free clipboard buffer */
|
||||
if (gui_input_clipboard)
|
||||
free(gui_input_clipboard);
|
||||
|
||||
|
||||
/* delete all windows */
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
while (gui_windows)
|
||||
{
|
||||
gui_window_free (gui_windows);
|
||||
/* TODO: destroy Gtk widgets */
|
||||
}
|
||||
gui_window_tree_free (&gui_windows_tree);
|
||||
|
||||
/* delete all buffers */
|
||||
while (gui_buffers)
|
||||
{
|
||||
gui_buffer_close (gui_buffers, 0);
|
||||
|
||||
/* delete all windows */
|
||||
while (gui_windows)
|
||||
gui_window_free (gui_windows);
|
||||
gui_window_tree_free (&gui_windows_tree);
|
||||
}
|
||||
|
||||
/* delete global history */
|
||||
gui_history_global_free ();
|
||||
@@ -236,5 +243,8 @@ gui_main_end (int clean_exit)
|
||||
/* reset title */
|
||||
if (CONFIG_BOOLEAN(config_look_set_title))
|
||||
gui_window_title_reset ();
|
||||
|
||||
/* end color */
|
||||
gui_color_end ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1122,6 +1122,7 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value
|
||||
case GUI_BAR_NUM_OPTIONS:
|
||||
break;
|
||||
}
|
||||
free (option_name);
|
||||
}
|
||||
|
||||
return ptr_option;
|
||||
|
||||
@@ -943,6 +943,7 @@ gui_buffer_close (struct t_gui_buffer *buffer, int switch_to_another)
|
||||
if (buffer->text_search_input)
|
||||
free (buffer->text_search_input);
|
||||
gui_nicklist_remove_all (buffer);
|
||||
gui_nicklist_remove_group (buffer, buffer->nicklist_root);
|
||||
if (buffer->highlight_words)
|
||||
free (buffer->highlight_words);
|
||||
if (buffer->highlight_tags_array)
|
||||
|
||||
@@ -364,6 +364,8 @@ gui_filter_free (struct t_gui_filter *filter)
|
||||
free (filter->buffer);
|
||||
if (filter->tags)
|
||||
free (filter->tags);
|
||||
if (filter->tags_array)
|
||||
string_free_exploded (filter->tags_array);
|
||||
if (filter->regex)
|
||||
free (filter->regex);
|
||||
if (filter->regex_prefix)
|
||||
|
||||
@@ -899,6 +899,13 @@ irc_config_server_create_default_options (struct t_config_section *section)
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (nicks)
|
||||
free (nicks);
|
||||
if (username)
|
||||
free (username);
|
||||
if (realname)
|
||||
free (realname);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user