summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2014-06-10 20:14:24 +0200
committerSébastien Helleu <flashcode@flashtux.org>2014-06-10 20:14:24 +0200
commitd0fa44865ce8e22edf5c23bb048556106795f560 (patch)
tree4276fe5d947b1d0835dc440d6064a52a0044da5c /src
parent955ed344c291c56e91291e15c6705baddefc2e2d (diff)
downloadweechat-d0fa44865ce8e22edf5c23bb048556106795f560.zip
core: fix potential memory leak with infolists not freed in plugins (debian #751108)
The memory leak should not happen if infolists are properly freed by plugins, and it happened only on unload of plugins (or exit).
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-infolist.h2
-rw-r--r--src/core/wee-upgrade-file.c2
-rw-r--r--src/core/wee-upgrade.c14
-rw-r--r--src/plugins/plugin-api.c34
-rw-r--r--src/plugins/weechat-plugin.h6
5 files changed, 29 insertions, 29 deletions
diff --git a/src/core/wee-infolist.h b/src/core/wee-infolist.h
index e3377d5f3..2342e9b7e 100644
--- a/src/core/wee-infolist.h
+++ b/src/core/wee-infolist.h
@@ -68,7 +68,7 @@ extern struct t_infolist *last_weechat_infolist;
/* list functions */
-extern struct t_infolist *infolist_new ();
+extern struct t_infolist *infolist_new (struct t_weechat_plugin *plugin);
extern int infolist_valid (struct t_infolist *infolist);
extern struct t_infolist_item *infolist_new_item (struct t_infolist *infolist);
extern struct t_infolist_var *infolist_new_var_integer (struct t_infolist_item *item,
diff --git a/src/core/wee-upgrade-file.c b/src/core/wee-upgrade-file.c
index 08088f223..b8d43b8ba 100644
--- a/src/core/wee-upgrade-file.c
+++ b/src/core/wee-upgrade-file.c
@@ -618,7 +618,7 @@ upgrade_file_read_object (struct t_upgrade_file *upgrade_file)
goto end;
}
- infolist = infolist_new ();
+ infolist = infolist_new (NULL);
if (!infolist)
{
UPGRADE_ERROR(_("read - infolist creation"), "");
diff --git a/src/core/wee-upgrade.c b/src/core/wee-upgrade.c
index b88e9d757..bb15aebeb 100644
--- a/src/core/wee-upgrade.c
+++ b/src/core/wee-upgrade.c
@@ -75,7 +75,7 @@ upgrade_weechat_save_history (struct t_upgrade_file *upgrade_file,
if (!last_history)
return 1;
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
return 0;
@@ -128,7 +128,7 @@ upgrade_weechat_save_buffers (struct t_upgrade_file *upgrade_file)
ptr_buffer = ptr_buffer->next_buffer)
{
/* save buffer */
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
return 0;
if (!gui_buffer_add_to_infolist (ptr_infolist, ptr_buffer))
@@ -146,7 +146,7 @@ upgrade_weechat_save_buffers (struct t_upgrade_file *upgrade_file)
/* save nicklist */
if (ptr_buffer->nicklist)
{
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
return 0;
if (!gui_nicklist_add_to_infolist (ptr_infolist, ptr_buffer, NULL))
@@ -166,7 +166,7 @@ upgrade_weechat_save_buffers (struct t_upgrade_file *upgrade_file)
for (ptr_line = ptr_buffer->own_lines->first_line; ptr_line;
ptr_line = ptr_line->next_line)
{
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
return 0;
if (!gui_line_add_to_infolist (ptr_infolist,
@@ -212,7 +212,7 @@ upgrade_weechat_save_misc (struct t_upgrade_file *upgrade_file)
struct t_infolist_item *ptr_item;
int rc;
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
return 0;
@@ -264,7 +264,7 @@ upgrade_weechat_save_hotlist (struct t_upgrade_file *upgrade_file)
for (ptr_hotlist = gui_hotlist; ptr_hotlist;
ptr_hotlist = ptr_hotlist->next_hotlist)
{
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
return 0;
if (!gui_hotlist_add_to_infolist (ptr_infolist, ptr_hotlist))
@@ -298,7 +298,7 @@ upgrade_weechat_save_layout_window_tree (struct t_upgrade_file *upgrade_file,
struct t_infolist *ptr_infolist;
int rc;
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (!ptr_infolist)
return 0;
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index c3ea57569..ca3c5ed5d 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -498,7 +498,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
if (pointer && (!gui_bar_valid (pointer)))
return NULL;
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (ptr_infolist)
{
if (pointer)
@@ -536,7 +536,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
if (pointer && (!gui_bar_item_valid (pointer)))
return NULL;
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (ptr_infolist)
{
if (pointer)
@@ -575,7 +575,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
if (pointer && (!gui_bar_window_valid (pointer)))
return NULL;
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (ptr_infolist)
{
if (pointer)
@@ -626,7 +626,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
if (pointer && (!gui_buffer_valid (pointer)))
return NULL;
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (ptr_infolist)
{
if (pointer)
@@ -670,7 +670,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
return NULL;
}
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (ptr_infolist)
{
for (ptr_line = ((struct t_gui_buffer *)pointer)->own_lines->first_line;
@@ -689,7 +689,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
}
else if (string_strcasecmp (infolist_name, "filter") == 0)
{
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (ptr_infolist)
{
for (ptr_filter = gui_filters; ptr_filter;
@@ -714,7 +714,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
if (pointer && (!gui_buffer_valid (pointer)))
return NULL;
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (ptr_infolist)
{
for (ptr_history = (pointer) ?
@@ -736,7 +736,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
if (pointer && !hook_valid (pointer))
return NULL;
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (ptr_infolist)
{
if (!hook_add_to_infolist (ptr_infolist, pointer, arguments))
@@ -749,7 +749,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
}
else if (string_strcasecmp (infolist_name, "hotlist") == 0)
{
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (ptr_infolist)
{
for (ptr_hotlist = gui_hotlist; ptr_hotlist;
@@ -766,7 +766,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
}
else if (string_strcasecmp (infolist_name, "key") == 0)
{
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (ptr_infolist)
{
if (arguments && arguments[0])
@@ -790,7 +790,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
}
else if (string_strcasecmp (infolist_name, "layout") == 0)
{
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (ptr_infolist)
{
for (ptr_layout = gui_layouts; ptr_layout;
@@ -811,7 +811,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
if (!pointer || (!gui_buffer_valid (pointer)))
return NULL;
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (ptr_infolist)
{
if (!gui_nicklist_add_to_infolist (ptr_infolist, pointer, arguments))
@@ -824,7 +824,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
}
else if (string_strcasecmp (infolist_name, "option") == 0)
{
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (ptr_infolist)
{
if (!config_file_add_to_infolist (ptr_infolist, arguments))
@@ -841,7 +841,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
if (pointer && (!plugin_valid (pointer)))
return NULL;
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (ptr_infolist)
{
if (pointer)
@@ -880,7 +880,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
if (pointer && (!proxy_valid (pointer)))
return NULL;
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (ptr_infolist)
{
if (pointer)
@@ -915,7 +915,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
}
else if (string_strcasecmp (infolist_name, "url_options") == 0)
{
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (ptr_infolist)
{
for (i = 0; url_options[i].name; i++)
@@ -935,7 +935,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
if (pointer && (!gui_window_valid (pointer)))
return NULL;
- ptr_infolist = infolist_new ();
+ ptr_infolist = infolist_new (NULL);
if (ptr_infolist)
{
if (pointer)
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index 7e491dda2..f37dd76c4 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -57,7 +57,7 @@ struct timeval;
* please change the date with current one; for a second change at same
* date, increment the 01, otherwise please keep 01.
*/
-#define WEECHAT_PLUGIN_API_VERSION "20140524-01"
+#define WEECHAT_PLUGIN_API_VERSION "20140610-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -832,7 +832,7 @@ struct t_weechat_plugin
struct t_hashtable *hashtable);
/* infolists */
- struct t_infolist *(*infolist_new) ();
+ struct t_infolist *(*infolist_new) (struct t_weechat_plugin *plugin);
struct t_infolist_item *(*infolist_new_item) (struct t_infolist *infolist);
struct t_infolist_var *(*infolist_new_var_integer) (struct t_infolist_item *item,
const char *name,
@@ -1628,7 +1628,7 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
/* infolists */
#define weechat_infolist_new() \
- weechat_plugin->infolist_new()
+ weechat_plugin->infolist_new(weechat_plugin)
#define weechat_infolist_new_item(__list) \
weechat_plugin->infolist_new_item(__list)
#define weechat_infolist_new_var_integer(__item, __name, __value) \