1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-08 18:53:12 +02:00

irc: fix memory leak when copying or renaming server

This commit is contained in:
Sebastien Helleu
2011-04-15 10:41:18 +02:00
parent 55aa584a2b
commit 377024835a
2 changed files with 37 additions and 29 deletions
+1
View File
@@ -47,6 +47,7 @@ Version 0.3.5 (under dev!)
* plugins: fix memory leaks when setting buffer callbacks after /upgrade
(plugins: irc, relay, xfer, scripts)
* aspell: fix spellers used after switch of window (bug #32811)
* irc: fix memory leak when copying or renaming server
* irc: do not rejoin channels where /part has been issued before reconnection
to server (bug #33029)
* irc: use nick color for users outside the channel
+36 -29
View File
@@ -1187,23 +1187,27 @@ irc_server_copy (struct t_irc_server *server, const char *new_name)
snprintf (mask, length, "irc.server.%s.*", server->name);
infolist = weechat_infolist_get ("option", NULL, mask);
free (mask);
while (weechat_infolist_next (infolist))
if (infolist)
{
if (!weechat_infolist_integer (infolist, "value_is_null"))
while (weechat_infolist_next (infolist))
{
option_name = weechat_infolist_string (infolist, "option_name");
pos = strrchr (option_name, '.');
if (pos)
if (!weechat_infolist_integer (infolist, "value_is_null"))
{
index_option = irc_server_search_option (pos + 1);
if (index_option >= 0)
option_name = weechat_infolist_string (infolist, "option_name");
pos = strrchr (option_name, '.');
if (pos)
{
weechat_config_option_set (new_server->options[index_option],
weechat_infolist_string (infolist, "value"),
1);
index_option = irc_server_search_option (pos + 1);
if (index_option >= 0)
{
weechat_config_option_set (new_server->options[index_option],
weechat_infolist_string (infolist, "value"),
1);
}
}
}
}
weechat_infolist_free (infolist);
}
}
@@ -1238,35 +1242,38 @@ irc_server_rename (struct t_irc_server *server, const char *new_server_name)
snprintf (mask, length, "irc.server.%s.*", server->name);
infolist = weechat_infolist_get ("option", NULL, mask);
free (mask);
while (weechat_infolist_next (infolist))
if (infolist)
{
weechat_config_search_with_string (weechat_infolist_string (infolist,
"full_name"),
NULL, NULL, &ptr_option,
NULL);
if (ptr_option)
while (weechat_infolist_next (infolist))
{
option_name = weechat_infolist_string (infolist, "option_name");
if (option_name)
weechat_config_search_with_string (weechat_infolist_string (infolist,
"full_name"),
NULL, NULL, &ptr_option,
NULL);
if (ptr_option)
{
pos_option = strrchr (option_name, '.');
if (pos_option)
option_name = weechat_infolist_string (infolist, "option_name");
if (option_name)
{
pos_option++;
length = strlen (new_server_name) + 1 + strlen (pos_option) + 1;
new_option_name = malloc (length);
if (new_option_name)
pos_option = strrchr (option_name, '.');
if (pos_option)
{
snprintf (new_option_name, length,
"%s.%s", new_server_name, pos_option);
weechat_config_option_rename (ptr_option, new_option_name);
free (new_option_name);
pos_option++;
length = strlen (new_server_name) + 1 + strlen (pos_option) + 1;
new_option_name = malloc (length);
if (new_option_name)
{
snprintf (new_option_name, length,
"%s.%s", new_server_name, pos_option);
weechat_config_option_rename (ptr_option, new_option_name);
free (new_option_name);
}
}
}
}
}
weechat_infolist_free (infolist);
}
weechat_infolist_free (infolist);
/* rename server */
if (server->name)