From 9fa560300ff99bb6f57a0b8350da83d34cd60711 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Tue, 30 Sep 2008 12:13:00 +0200 Subject: Fix some memory leaks --- src/core/wee-config-file.c | 10 ++++++++-- src/core/wee-hook.c | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c index a972cd5c6..67524806f 100644 --- a/src/core/wee-config-file.c +++ b/src/core/wee-config-file.c @@ -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; diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index d059c6d25..56861714f 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -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: -- cgit v1.2.3