mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-13 09:10:20 +00:00
Use glib for all allocations
- Removes need to check for malloc failure - Removes need for NULL checks on free - Adds checks for integer overflows - Removes some extra memset calls - Removes chance of mixing libc and glib malloc/free
This commit is contained in:
@@ -61,7 +61,7 @@ list_addentry (GSList ** list, char *cmd, char *name)
|
||||
cmd_len = strlen (cmd) + 1;
|
||||
name_len = strlen (name) + 1;
|
||||
|
||||
pop = malloc (sizeof (struct popup) + cmd_len + name_len);
|
||||
pop = g_malloc (sizeof (struct popup) + cmd_len + name_len);
|
||||
pop->name = (char *) pop + sizeof (struct popup);
|
||||
pop->cmd = pop->name + name_len;
|
||||
|
||||
@@ -133,13 +133,13 @@ list_loadconf (char *file, GSList ** list, char *defaultconf)
|
||||
abort ();
|
||||
}
|
||||
|
||||
ibuf = malloc (st.st_size);
|
||||
ibuf = g_malloc (st.st_size);
|
||||
read (fd, ibuf, st.st_size);
|
||||
close (fd);
|
||||
|
||||
list_load_from_data (list, ibuf, st.st_size);
|
||||
|
||||
free (ibuf);
|
||||
g_free (ibuf);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -149,7 +149,7 @@ list_free (GSList ** list)
|
||||
while (*list)
|
||||
{
|
||||
data = (void *) (*list)->data;
|
||||
free (data);
|
||||
g_free (data);
|
||||
*list = g_slist_remove (*list, data);
|
||||
}
|
||||
}
|
||||
@@ -166,7 +166,7 @@ list_delentry (GSList ** list, char *name)
|
||||
if (!g_ascii_strcasecmp (name, pop->name))
|
||||
{
|
||||
*list = g_slist_remove (*list, pop);
|
||||
free (pop);
|
||||
g_free (pop);
|
||||
return 1;
|
||||
}
|
||||
alist = alist->next;
|
||||
@@ -647,7 +647,7 @@ get_default_language (void)
|
||||
|
||||
if (lang_no >= 0)
|
||||
{
|
||||
free (lang);
|
||||
g_free (lang);
|
||||
return lang_no;
|
||||
}
|
||||
|
||||
@@ -656,7 +656,7 @@ get_default_language (void)
|
||||
|
||||
lang_no = find_language_number (lang);
|
||||
|
||||
free (lang);
|
||||
g_free (lang);
|
||||
|
||||
return lang_no >= 0 ? lang_no : find_language_number ("en");
|
||||
}
|
||||
@@ -1226,7 +1226,7 @@ cmd_set (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
if (erase || *val)
|
||||
{
|
||||
/* save the previous value until we print it out */
|
||||
prev_string = (char*) malloc (vars[i].len + 1);
|
||||
prev_string = g_malloc (vars[i].len + 1);
|
||||
strncpy (prev_string, (char *) &prefs + vars[i].offset, vars[i].len);
|
||||
|
||||
/* update the variable */
|
||||
@@ -1238,7 +1238,7 @@ cmd_set (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
PrintTextf (sess, "%s set to: %s (was: %s)\n", var, (char *) &prefs + vars[i].offset, prev_string);
|
||||
}
|
||||
|
||||
free (prev_string);
|
||||
g_free (prev_string);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -208,7 +208,7 @@ chanopt_find (char *network, char *channel, gboolean add_new)
|
||||
return NULL;
|
||||
|
||||
/* allocate a new one */
|
||||
co = g_malloc0 (sizeof (chanopt_in_memory));
|
||||
co = g_new0 (chanopt_in_memory, 1);
|
||||
co->channel = g_strdup (channel);
|
||||
co->network = g_strdup (network);
|
||||
|
||||
|
||||
@@ -44,12 +44,12 @@ ctcp_reply (session *sess, char *nick, char *word[], char *word_eol[],
|
||||
{
|
||||
char tbuf[4096]; /* can receive 2048 from IRC, so this is enough */
|
||||
|
||||
conf = strdup (conf);
|
||||
conf = g_strdup (conf);
|
||||
/* process %C %B etc */
|
||||
check_special_chars (conf, TRUE);
|
||||
auto_insert (tbuf, sizeof (tbuf), conf, word, word_eol, "", "", word_eol[5],
|
||||
server_get_network (sess->server, TRUE), "", "", nick, "");
|
||||
free (conf);
|
||||
g_free (conf);
|
||||
handle_command (sess, tbuf, FALSE);
|
||||
}
|
||||
|
||||
|
||||
@@ -309,7 +309,7 @@ dcc_lookup_proxy (char *host, struct sockaddr_in *addr)
|
||||
memcpy (&addr->sin_addr, &cache_addr, 4);
|
||||
return TRUE;
|
||||
}
|
||||
free (cache_host);
|
||||
g_free (cache_host);
|
||||
cache_host = NULL;
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ dcc_lookup_proxy (char *host, struct sockaddr_in *addr)
|
||||
{
|
||||
memcpy (&addr->sin_addr, h->h_addr, 4);
|
||||
memcpy (&cache_addr, h->h_addr, 4);
|
||||
cache_host = strdup (host);
|
||||
cache_host = g_strdup (host);
|
||||
/* cppcheck-suppress memleak */
|
||||
return TRUE;
|
||||
}
|
||||
@@ -406,7 +406,7 @@ dcc_close (struct DCC *dcc, int dccstat, int destroy)
|
||||
dcc->dccstat = dccstat;
|
||||
if (dcc->dccchat)
|
||||
{
|
||||
free (dcc->dccchat);
|
||||
g_free (dcc->dccchat);
|
||||
dcc->dccchat = NULL;
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ dcc_close (struct DCC *dcc, int dccstat, int destroy)
|
||||
g_free (dcc->proxy);
|
||||
g_free (dcc->file);
|
||||
g_free (dcc->destfile);
|
||||
free (dcc->nick);
|
||||
g_free (dcc->nick);
|
||||
g_free (dcc);
|
||||
return;
|
||||
}
|
||||
@@ -888,8 +888,7 @@ dcc_connect_finished (GIOChannel *source, GIOCondition condition, struct DCC *dc
|
||||
dcc_open_query (dcc->serv, dcc->nick);
|
||||
case TYPE_CHATRECV: /* normal chat */
|
||||
dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, dcc_read_chat, dcc);
|
||||
dcc->dccchat = malloc (sizeof (struct dcc_chat));
|
||||
dcc->dccchat->pos = 0;
|
||||
dcc->dccchat = g_new0 (struct dcc_chat, 1);
|
||||
EMIT_SIGNAL (XP_TE_DCCCONCHAT, dcc->serv->front_session,
|
||||
dcc->nick, host, NULL, NULL, 0);
|
||||
break;
|
||||
@@ -1369,12 +1368,6 @@ dcc_proxy_connect (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
|
||||
return TRUE;
|
||||
|
||||
dcc->proxy = g_new0 (struct proxy_state, 1);
|
||||
if (!dcc->proxy)
|
||||
{
|
||||
dcc->dccstat = STAT_FAILED;
|
||||
fe_dcc_update (dcc);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
switch (prefs.hex_net_proxy_type)
|
||||
{
|
||||
@@ -1463,9 +1456,7 @@ dcc_send_data (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
|
||||
else if (!dcc->wiotag)
|
||||
dcc->wiotag = fe_input_add (sok, FIA_WRITE, dcc_send_data, dcc);
|
||||
|
||||
buf = malloc (prefs.hex_dcc_blocksize);
|
||||
if (!buf)
|
||||
return TRUE;
|
||||
buf = g_malloc (prefs.hex_dcc_blocksize);
|
||||
|
||||
lseek (dcc->fp, dcc->pos, SEEK_SET);
|
||||
len = read (dcc->fp, buf, prefs.hex_dcc_blocksize);
|
||||
@@ -1476,7 +1467,7 @@ dcc_send_data (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
|
||||
if (sent < 0 && !(would_block ()))
|
||||
{
|
||||
abortit:
|
||||
free (buf);
|
||||
g_free (buf);
|
||||
EMIT_SIGNAL (XP_TE_DCCSENDFAIL, dcc->serv->front_session,
|
||||
file_part (dcc->file), dcc->nick,
|
||||
errorstring (sock_error ()), NULL, 0);
|
||||
@@ -1500,7 +1491,7 @@ abortit:
|
||||
}
|
||||
}
|
||||
|
||||
free (buf);
|
||||
g_free (buf);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1630,8 +1621,7 @@ dcc_accept (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
|
||||
case TYPE_CHATSEND:
|
||||
dcc_open_query (dcc->serv, dcc->nick);
|
||||
dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, dcc_read_chat, dcc);
|
||||
dcc->dccchat = malloc (sizeof (struct dcc_chat));
|
||||
dcc->dccchat->pos = 0;
|
||||
dcc->dccchat = g_new0 (struct dcc_chat, 1);
|
||||
EMIT_SIGNAL (XP_TE_DCCCONCHAT, dcc->serv->front_session,
|
||||
dcc->nick, host, NULL, NULL, 0);
|
||||
break;
|
||||
@@ -1897,7 +1887,7 @@ dcc_send (struct session *sess, char *to, char *filename, gint64 maxcps, int pas
|
||||
}
|
||||
filename++;
|
||||
}
|
||||
dcc->nick = strdup (to);
|
||||
dcc->nick = g_strdup (to);
|
||||
if (prefs.hex_gui_autoopen_send)
|
||||
{
|
||||
if (fe_dcc_open_send_win (TRUE)) /* already open? add */
|
||||
@@ -2005,9 +1995,8 @@ dcc_change_nick (struct server *serv, char *oldnick, char *newnick)
|
||||
{
|
||||
if (!serv->p_cmp (dcc->nick, oldnick))
|
||||
{
|
||||
if (dcc->nick)
|
||||
free (dcc->nick);
|
||||
dcc->nick = strdup (newnick);
|
||||
g_free (dcc->nick);
|
||||
dcc->nick = g_strdup (newnick);
|
||||
}
|
||||
}
|
||||
list = list->next;
|
||||
@@ -2257,11 +2246,6 @@ static struct DCC *
|
||||
new_dcc (void)
|
||||
{
|
||||
struct DCC *dcc = g_new0 (struct DCC, 1);
|
||||
if (!dcc)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dcc->sok = -1;
|
||||
dcc->fp = -1;
|
||||
dcc_list = g_slist_prepend (dcc_list, dcc);
|
||||
@@ -2312,7 +2296,7 @@ dcc_chat (struct session *sess, char *nick, int passive)
|
||||
dcc->serv = sess->server;
|
||||
dcc->dccstat = STAT_QUEUED;
|
||||
dcc->type = TYPE_CHATSEND;
|
||||
dcc->nick = strdup (nick);
|
||||
dcc->nick = g_strdup (nick);
|
||||
if (passive || dcc_listen_init (dcc, sess))
|
||||
{
|
||||
if (prefs.hex_gui_autoopen_chat)
|
||||
@@ -2412,7 +2396,7 @@ dcc_add_chat (session *sess, char *nick, int port, guint32 addr, int pasvid)
|
||||
dcc->addr = addr;
|
||||
dcc->port = port;
|
||||
dcc->pasvid = pasvid;
|
||||
dcc->nick = strdup (nick);
|
||||
dcc->nick = g_strdup (nick);
|
||||
dcc->starttime = time (0);
|
||||
|
||||
EMIT_SIGNAL (XP_TE_DCCCHATOFFER, sess->server->front_session, nick,
|
||||
@@ -2484,7 +2468,7 @@ dcc_add_file (session *sess, char *file, guint64 size, int port, char *nick, gui
|
||||
dcc->port = port;
|
||||
dcc->pasvid = pasvid;
|
||||
dcc->size = size;
|
||||
dcc->nick = strdup (nick);
|
||||
dcc->nick = g_strdup (nick);
|
||||
dcc->maxcps = prefs.hex_dcc_max_get_cps;
|
||||
|
||||
update_is_resumable (dcc);
|
||||
|
||||
@@ -456,12 +456,7 @@ session_new (server *serv, char *from, int type, int focus)
|
||||
{
|
||||
session *sess;
|
||||
|
||||
sess = malloc (sizeof (struct session));
|
||||
if (sess == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
memset (sess, 0, sizeof (struct session));
|
||||
sess = g_new0 (struct session, 1);
|
||||
|
||||
sess->server = serv;
|
||||
sess->logfd = -1;
|
||||
@@ -543,9 +538,8 @@ exec_notify_kill (session * sess)
|
||||
waitpid (re->childpid, NULL, WNOHANG);
|
||||
fe_input_remove (re->iotag);
|
||||
close (re->myfd);
|
||||
if (re->linebuf)
|
||||
free(re->linebuf);
|
||||
free (re);
|
||||
g_free(re->linebuf);
|
||||
g_free (re);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -651,10 +645,8 @@ session_free (session *killsess)
|
||||
send_quit_or_part (killsess);
|
||||
|
||||
history_free (&killsess->history);
|
||||
if (killsess->topic)
|
||||
free (killsess->topic);
|
||||
if (killsess->current_modes)
|
||||
free (killsess->current_modes);
|
||||
g_free (killsess->topic);
|
||||
g_free (killsess->current_modes);
|
||||
|
||||
fe_session_callback (killsess);
|
||||
|
||||
@@ -665,7 +657,7 @@ session_free (session *killsess)
|
||||
current_sess = sess_list->data;
|
||||
}
|
||||
|
||||
free (killsess);
|
||||
g_free (killsess);
|
||||
|
||||
if (!sess_list && !in_hexchat_exit)
|
||||
hexchat_exit (); /* sess_list is empty, quit! */
|
||||
@@ -1029,11 +1021,11 @@ main (int argc, char *argv[])
|
||||
if ((strcmp (argv[i], "-d") == 0 || strcmp (argv[i], "--cfgdir") == 0)
|
||||
&& i + 1 < argc)
|
||||
{
|
||||
xdir = strdup (argv[i + 1]);
|
||||
xdir = g_strdup (argv[i + 1]);
|
||||
}
|
||||
else if (strncmp (argv[i], "--cfgdir=", 9) == 0)
|
||||
{
|
||||
xdir = strdup (argv[i] + 9);
|
||||
xdir = g_strdup (argv[i] + 9);
|
||||
}
|
||||
|
||||
if (xdir != NULL)
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
#include "history.h"
|
||||
|
||||
void
|
||||
history_add (struct history *his, char *text)
|
||||
{
|
||||
if (his->lines[his->realpos])
|
||||
free (his->lines[his->realpos]);
|
||||
his->lines[his->realpos] = strdup (text);
|
||||
g_free (his->lines[his->realpos]);
|
||||
his->lines[his->realpos] = g_strdup (text);
|
||||
his->realpos++;
|
||||
if (his->realpos == HISTORY_SIZE)
|
||||
his->realpos = 0;
|
||||
@@ -40,7 +40,7 @@ history_free (struct history *his)
|
||||
{
|
||||
if (his->lines[i])
|
||||
{
|
||||
free (his->lines[i]);
|
||||
g_free (his->lines[i]);
|
||||
his->lines[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ identd (char *username)
|
||||
sok = socket (AF_INET, SOCK_STREAM, 0);
|
||||
if (sok == INVALID_SOCKET)
|
||||
{
|
||||
free (username);
|
||||
g_free (username);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -56,14 +56,14 @@ identd (char *username)
|
||||
if (bind (sok, (struct sockaddr *) &addr, sizeof (addr)) == SOCKET_ERROR)
|
||||
{
|
||||
closesocket (sok);
|
||||
free (username);
|
||||
g_free (username);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (listen (sok, 1) == SOCKET_ERROR)
|
||||
{
|
||||
closesocket (sok);
|
||||
free (username);
|
||||
g_free (username);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ identd (char *username)
|
||||
closesocket (sok);
|
||||
if (read_sok == INVALID_SOCKET)
|
||||
{
|
||||
free (username);
|
||||
g_free (username);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ identd (char *username)
|
||||
|
||||
sleep (1);
|
||||
closesocket (read_sok);
|
||||
free (username);
|
||||
g_free (username);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ identd_ipv6 (char *username)
|
||||
sok = socket (AF_INET6, SOCK_STREAM, 0);
|
||||
if (sok == INVALID_SOCKET)
|
||||
{
|
||||
free (username);
|
||||
g_free (username);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -132,14 +132,14 @@ identd_ipv6 (char *username)
|
||||
if (bind (sok, (struct sockaddr *) &addr, sizeof (addr)) == SOCKET_ERROR)
|
||||
{
|
||||
closesocket (sok);
|
||||
free (username);
|
||||
g_free (username);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (listen (sok, 1) == SOCKET_ERROR)
|
||||
{
|
||||
closesocket (sok);
|
||||
free (username);
|
||||
g_free (username);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ identd_ipv6 (char *username)
|
||||
closesocket (sok);
|
||||
if (read_sok == INVALID_SOCKET)
|
||||
{
|
||||
free (username);
|
||||
g_free (username);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ identd_ipv6 (char *username)
|
||||
|
||||
sleep (1);
|
||||
closesocket (read_sok);
|
||||
free (username);
|
||||
g_free (username);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -188,7 +188,7 @@ identd_start (char *username)
|
||||
{
|
||||
identd_ipv6_is_running = TRUE;
|
||||
CloseHandle (CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) identd_ipv6,
|
||||
strdup (username), 0, &tidv6));
|
||||
g_strdup (username), 0, &tidv6));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -196,6 +196,6 @@ identd_start (char *username)
|
||||
{
|
||||
identd_is_running = TRUE;
|
||||
CloseHandle (CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) identd,
|
||||
strdup (username), 0, &tid));
|
||||
g_strdup (username), 0, &tid));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ static int ignored_total = 0;
|
||||
struct ignore *
|
||||
ignore_exists (char *mask)
|
||||
{
|
||||
struct ignore *ig = 0;
|
||||
struct ignore *ig = NULL;
|
||||
GSList *list;
|
||||
|
||||
list = ignore_list;
|
||||
@@ -79,7 +79,7 @@ ignore_exists (char *mask)
|
||||
int
|
||||
ignore_add (char *mask, int type, gboolean overwrite)
|
||||
{
|
||||
struct ignore *ig = 0;
|
||||
struct ignore *ig = NULL;
|
||||
int change_only = FALSE;
|
||||
|
||||
/* first check if it's already ignored */
|
||||
@@ -88,12 +88,9 @@ ignore_add (char *mask, int type, gboolean overwrite)
|
||||
change_only = TRUE;
|
||||
|
||||
if (!change_only)
|
||||
ig = malloc (sizeof (struct ignore));
|
||||
ig = g_new (struct ignore, 1);
|
||||
|
||||
if (!ig)
|
||||
return 0;
|
||||
|
||||
ig->mask = strdup (mask);
|
||||
ig->mask = g_strdup (mask);
|
||||
|
||||
if (!overwrite && change_only)
|
||||
ig->type |= type;
|
||||
@@ -192,8 +189,8 @@ ignore_del (char *mask, struct ignore *ig)
|
||||
if (ig)
|
||||
{
|
||||
ignore_list = g_slist_remove (ignore_list, ig);
|
||||
free (ig->mask);
|
||||
free (ig);
|
||||
g_free (ig->mask);
|
||||
g_free (ig);
|
||||
fe_ignore_update (1);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -265,7 +262,7 @@ ignore_read_next_entry (char *my_cfg, struct ignore *ignore)
|
||||
my_cfg = cfg_get_str (my_cfg, "mask", tbuf, sizeof (tbuf));
|
||||
if (!my_cfg)
|
||||
return NULL;
|
||||
ignore->mask = strdup (tbuf);
|
||||
ignore->mask = g_strdup (tbuf);
|
||||
}
|
||||
if (my_cfg)
|
||||
{
|
||||
@@ -281,7 +278,7 @@ ignore_load ()
|
||||
struct ignore *ignore;
|
||||
struct stat st;
|
||||
char *cfg, *my_cfg;
|
||||
int fh, i;
|
||||
int fh;
|
||||
|
||||
fh = hexchat_open_file ("ignore.conf", O_RDONLY, 0, 0);
|
||||
if (fh != -1)
|
||||
@@ -289,22 +286,18 @@ ignore_load ()
|
||||
fstat (fh, &st);
|
||||
if (st.st_size)
|
||||
{
|
||||
cfg = malloc (st.st_size + 1);
|
||||
cfg[0] = '\0';
|
||||
i = read (fh, cfg, st.st_size);
|
||||
if (i >= 0)
|
||||
cfg[i] = '\0';
|
||||
cfg = g_malloc0 (st.st_size + 1);
|
||||
read (fh, cfg, st.st_size);
|
||||
my_cfg = cfg;
|
||||
while (my_cfg)
|
||||
{
|
||||
ignore = malloc (sizeof (struct ignore));
|
||||
memset (ignore, 0, sizeof (struct ignore));
|
||||
ignore = g_new0 (struct ignore, 1);
|
||||
if ((my_cfg = ignore_read_next_entry (my_cfg, ignore)))
|
||||
ignore_list = g_slist_prepend (ignore_list, ignore);
|
||||
else
|
||||
free (ignore);
|
||||
g_free (ignore);
|
||||
}
|
||||
free (cfg);
|
||||
g_free (cfg);
|
||||
}
|
||||
close (fh);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ clear_channel (session *sess)
|
||||
|
||||
if (sess->current_modes)
|
||||
{
|
||||
free (sess->current_modes);
|
||||
g_free (sess->current_modes);
|
||||
sess->current_modes = NULL;
|
||||
}
|
||||
|
||||
@@ -81,9 +81,8 @@ clear_channel (session *sess)
|
||||
void
|
||||
set_topic (session *sess, char *topic, char *stripped_topic)
|
||||
{
|
||||
if (sess->topic)
|
||||
free (sess->topic);
|
||||
sess->topic = strdup (stripped_topic);
|
||||
g_free (sess->topic);
|
||||
sess->topic = g_strdup (stripped_topic);
|
||||
fe_set_topic (sess, topic, stripped_topic);
|
||||
}
|
||||
|
||||
@@ -968,14 +967,14 @@ inbound_notice (server *serv, char *to, char *nick, char *msg, char *ip, int id,
|
||||
/* guess where chanserv meant to post this -sigh- */
|
||||
if (!g_ascii_strcasecmp (nick, "ChanServ") && !find_dialog (serv, nick))
|
||||
{
|
||||
char *dest = strdup (msg + 1);
|
||||
char *dest = g_strdup (msg + 1);
|
||||
char *end = strchr (dest, ']');
|
||||
if (end)
|
||||
{
|
||||
*end = 0;
|
||||
sess = find_channel (serv, dest);
|
||||
}
|
||||
free (dest);
|
||||
g_free (dest);
|
||||
}
|
||||
}
|
||||
if (!sess)
|
||||
@@ -1454,8 +1453,7 @@ inbound_user_info (session *sess, char *chan, char *user, char *host,
|
||||
|
||||
if (user && host)
|
||||
{
|
||||
uhost = g_malloc (strlen (user) + strlen (host) + 2);
|
||||
sprintf (uhost, "%s@%s", user, host);
|
||||
uhost = g_strdup_printf ("%s@%s", user, host);
|
||||
}
|
||||
|
||||
if (chan)
|
||||
|
||||
@@ -331,7 +331,7 @@ record_chan_mode (session *sess, char sign, char mode, char *arg)
|
||||
current = g_string_erase(current, argument_offset+1, argument_length-1);
|
||||
current = g_string_insert(current, argument_offset+1, arg);
|
||||
|
||||
free(sess->current_modes);
|
||||
g_free(sess->current_modes);
|
||||
sess->current_modes = g_string_free(current, FALSE);
|
||||
}
|
||||
}
|
||||
@@ -348,7 +348,7 @@ record_chan_mode (session *sess, char sign, char mode, char *arg)
|
||||
current = g_string_append(current, arg);
|
||||
}
|
||||
|
||||
free(sess->current_modes);
|
||||
g_free(sess->current_modes);
|
||||
sess->current_modes = g_string_free(current, FALSE);
|
||||
}
|
||||
}
|
||||
@@ -361,7 +361,7 @@ record_chan_mode (session *sess, char sign, char mode, char *arg)
|
||||
/* remove the mode character */
|
||||
current = g_string_erase(current, mode_pos, 1);
|
||||
|
||||
free(sess->current_modes);
|
||||
g_free(sess->current_modes);
|
||||
sess->current_modes = g_string_free(current, FALSE);
|
||||
}
|
||||
}
|
||||
@@ -374,12 +374,13 @@ mode_cat (char *str, char *addition)
|
||||
if (str)
|
||||
{
|
||||
len = strlen (str) + strlen (addition) + 2;
|
||||
str = realloc (str, len);
|
||||
str = g_realloc (str, len);
|
||||
strcat (str, " ");
|
||||
strcat (str, addition);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
str = strdup (addition);
|
||||
str = g_strdup (addition);
|
||||
}
|
||||
|
||||
return str;
|
||||
@@ -560,12 +561,12 @@ handle_single_mode (mode_run *mr, char sign, char mode, char *nick,
|
||||
{
|
||||
if (*arg)
|
||||
{
|
||||
char *buf = malloc (strlen (chan) + strlen (arg) + 2);
|
||||
sprintf (buf, "%s %s", chan, arg);
|
||||
char *buf = g_strdup_printf ("%s %s", chan, arg);
|
||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_CHANMODEGEN, sess, nick, outbuf,
|
||||
outbuf + 2, buf, 0, tags_data->timestamp);
|
||||
free (buf);
|
||||
} else
|
||||
g_free (buf);
|
||||
}
|
||||
else
|
||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_CHANMODEGEN, sess, nick, outbuf,
|
||||
outbuf + 2, chan, 0, tags_data->timestamp);
|
||||
}
|
||||
@@ -635,7 +636,7 @@ mode_print_grouped (session *sess, char *nick, mode_run *mr,
|
||||
{
|
||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_CHANOP, sess, nick, mr->op, NULL, NULL, 0,
|
||||
tags_data->timestamp);
|
||||
free (mr->op);
|
||||
g_free(mr->op);
|
||||
mr->op = NULL;
|
||||
}
|
||||
|
||||
@@ -643,7 +644,7 @@ mode_print_grouped (session *sess, char *nick, mode_run *mr,
|
||||
{
|
||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_CHANDEOP, sess, nick, mr->deop, NULL, NULL,
|
||||
0, tags_data->timestamp);
|
||||
free (mr->deop);
|
||||
g_free(mr->deop);
|
||||
mr->deop = NULL;
|
||||
}
|
||||
|
||||
@@ -651,7 +652,7 @@ mode_print_grouped (session *sess, char *nick, mode_run *mr,
|
||||
{
|
||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_CHANVOICE, sess, nick, mr->voice, NULL, NULL,
|
||||
0, tags_data->timestamp);
|
||||
free (mr->voice);
|
||||
g_free(mr->voice);
|
||||
mr->voice = NULL;
|
||||
}
|
||||
|
||||
@@ -659,7 +660,7 @@ mode_print_grouped (session *sess, char *nick, mode_run *mr,
|
||||
{
|
||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_CHANDEVOICE, sess, nick, mr->devoice, NULL,
|
||||
NULL, 0, tags_data->timestamp);
|
||||
free (mr->devoice);
|
||||
g_free(mr->devoice);
|
||||
mr->devoice = NULL;
|
||||
}
|
||||
}
|
||||
@@ -717,9 +718,8 @@ handle_mode (server * serv, char *word[], char *word_eol[],
|
||||
|
||||
if (numeric_324 && !using_front_tab)
|
||||
{
|
||||
if (sess->current_modes)
|
||||
free (sess->current_modes);
|
||||
sess->current_modes = strdup (word_eol[offset+1]);
|
||||
g_free (sess->current_modes);
|
||||
sess->current_modes = g_strdup (word_eol[offset+1]);
|
||||
}
|
||||
|
||||
sign = *modes;
|
||||
@@ -799,30 +799,29 @@ inbound_005 (server * serv, char *word[], const message_tags_data *tags_data)
|
||||
serv->modes_per_line = atoi (word[w] + 6);
|
||||
} else if (strncmp (word[w], "CHANTYPES=", 10) == 0)
|
||||
{
|
||||
free (serv->chantypes);
|
||||
serv->chantypes = strdup (word[w] + 10);
|
||||
g_free (serv->chantypes);
|
||||
serv->chantypes = g_strdup (word[w] + 10);
|
||||
} else if (strncmp (word[w], "CHANMODES=", 10) == 0)
|
||||
{
|
||||
free (serv->chanmodes);
|
||||
serv->chanmodes = strdup (word[w] + 10);
|
||||
g_free (serv->chanmodes);
|
||||
serv->chanmodes = g_strdup (word[w] + 10);
|
||||
} else if (strncmp (word[w], "PREFIX=", 7) == 0)
|
||||
{
|
||||
pre = strchr (word[w] + 7, ')');
|
||||
if (pre)
|
||||
{
|
||||
pre[0] = 0; /* NULL out the ')' */
|
||||
free (serv->nick_prefixes);
|
||||
free (serv->nick_modes);
|
||||
serv->nick_prefixes = strdup (pre + 1);
|
||||
serv->nick_modes = strdup (word[w] + 8);
|
||||
g_free (serv->nick_prefixes);
|
||||
g_free (serv->nick_modes);
|
||||
serv->nick_prefixes = g_strdup (pre + 1);
|
||||
serv->nick_modes = g_strdup (word[w] + 8);
|
||||
} else
|
||||
{
|
||||
/* bad! some ircds don't give us the modes. */
|
||||
/* in this case, we use it only to strip /NAMES */
|
||||
serv->bad_prefix = TRUE;
|
||||
if (serv->bad_nick_prefixes)
|
||||
free (serv->bad_nick_prefixes);
|
||||
serv->bad_nick_prefixes = strdup (word[w] + 7);
|
||||
g_free (serv->bad_nick_prefixes);
|
||||
serv->bad_nick_prefixes = g_strdup (word[w] + 7);
|
||||
}
|
||||
} else if (strncmp (word[w], "WATCH=", 6) == 0)
|
||||
{
|
||||
@@ -832,10 +831,6 @@ inbound_005 (server * serv, char *word[], const message_tags_data *tags_data)
|
||||
serv->supports_monitor = TRUE;
|
||||
} else if (strncmp (word[w], "NETWORK=", 8) == 0)
|
||||
{
|
||||
/* if (serv->networkname)
|
||||
free (serv->networkname);
|
||||
serv->networkname = strdup (word[w] + 8);*/
|
||||
|
||||
if (serv->server_session->type == SESS_SERVER)
|
||||
{
|
||||
safe_strcpy (serv->server_session->channel, word[w] + 8, CHANLEN);
|
||||
|
||||
@@ -69,18 +69,13 @@ net_store_destroy (netstore * ns)
|
||||
if (ns->ip6_hostent)
|
||||
freeaddrinfo (ns->ip6_hostent);
|
||||
#endif
|
||||
free (ns);
|
||||
g_free (ns);
|
||||
}
|
||||
|
||||
netstore *
|
||||
net_store_new (void)
|
||||
{
|
||||
netstore *ns;
|
||||
|
||||
ns = malloc (sizeof (netstore));
|
||||
memset (ns, 0, sizeof (netstore));
|
||||
|
||||
return ns;
|
||||
return g_new0 (netstore, 1);
|
||||
}
|
||||
|
||||
#ifndef USE_IPV6
|
||||
@@ -120,8 +115,8 @@ net_resolve (netstore * ns, char *hostname, int port, char **real_host)
|
||||
ns->addr.sin_port = htons (port);
|
||||
ns->addr.sin_family = AF_INET;
|
||||
|
||||
*real_host = strdup (ns->ip4_hostent->h_name);
|
||||
return strdup (inet_ntoa (ns->addr.sin_addr));
|
||||
*real_host = g_strdup (ns->ip4_hostent->h_name);
|
||||
return g_strdup (inet_ntoa (ns->addr.sin_addr));
|
||||
}
|
||||
|
||||
int
|
||||
@@ -232,11 +227,11 @@ net_resolve (netstore * ns, char *hostname, int port, char **real_host)
|
||||
ipstring, sizeof (ipstring), NULL, 0, NI_NUMERICHOST);
|
||||
|
||||
if (ns->ip6_hostent->ai_canonname)
|
||||
*real_host = strdup (ns->ip6_hostent->ai_canonname);
|
||||
*real_host = g_strdup (ns->ip6_hostent->ai_canonname);
|
||||
else
|
||||
*real_host = strdup (hostname);
|
||||
*real_host = g_strdup (hostname);
|
||||
|
||||
return strdup (ipstring);
|
||||
return g_strdup (ipstring);
|
||||
}
|
||||
|
||||
/* the only thing making this interface unclean, this shitty sok4, sok6 business */
|
||||
@@ -310,15 +305,15 @@ net_store_fill_any (netstore *ns)
|
||||
struct sockaddr_in *sin;
|
||||
|
||||
ai = ns->ip6_hostent;
|
||||
if (!ai) {
|
||||
ai = malloc (sizeof (struct addrinfo));
|
||||
memset (ai, 0, sizeof (struct addrinfo));
|
||||
if (ai == NULL)
|
||||
{
|
||||
ai = g_new0 (struct addrinfo, 1);
|
||||
ns->ip6_hostent = ai;
|
||||
}
|
||||
sin = (struct sockaddr_in *)ai->ai_addr;
|
||||
if (!sin) {
|
||||
sin = malloc (sizeof (struct sockaddr_in));
|
||||
memset (sin, 0, sizeof (struct sockaddr_in));
|
||||
if (sin == NULL)
|
||||
{
|
||||
sin = g_new0 (struct sockaddr_in, 1);
|
||||
ai->ai_addr = (struct sockaddr *)sin;
|
||||
}
|
||||
ai->ai_family = AF_INET;
|
||||
@@ -336,15 +331,15 @@ net_store_fill_v4 (netstore *ns, guint32 addr, int port)
|
||||
struct sockaddr_in *sin;
|
||||
|
||||
ai = ns->ip6_hostent;
|
||||
if (!ai) {
|
||||
ai = malloc (sizeof (struct addrinfo));
|
||||
memset (ai, 0, sizeof (struct addrinfo));
|
||||
if (ai == NULL)
|
||||
{
|
||||
ai = g_new0 (struct addrinfo, 1);
|
||||
ns->ip6_hostent = ai;
|
||||
}
|
||||
sin = (struct sockaddr_in *)ai->ai_addr;
|
||||
if (!sin) {
|
||||
sin = malloc (sizeof (struct sockaddr_in));
|
||||
memset (sin, 0, sizeof (struct sockaddr_in));
|
||||
if (sin == NULL)
|
||||
{
|
||||
sin = g_new0 (struct sockaddr_in, 1);
|
||||
ai->ai_addr = (struct sockaddr *)sin;
|
||||
}
|
||||
ai->ai_family = AF_INET;
|
||||
|
||||
@@ -47,7 +47,7 @@ int notify_tag = 0;
|
||||
static char *
|
||||
despacify_dup (char *str)
|
||||
{
|
||||
char *p, *res = malloc (strlen (str) + 1);
|
||||
char *p, *res = g_malloc (strlen (str) + 1);
|
||||
|
||||
p = res;
|
||||
while (1)
|
||||
@@ -70,11 +70,11 @@ notify_netcmp (char *str, void *serv)
|
||||
|
||||
if (rfc_casecmp (str, net) == 0)
|
||||
{
|
||||
free (net);
|
||||
g_free (net);
|
||||
return 0; /* finish & return FALSE from token_foreach() */
|
||||
}
|
||||
|
||||
free (net);
|
||||
g_free (net);
|
||||
return 1; /* keep going... */
|
||||
}
|
||||
|
||||
@@ -111,14 +111,10 @@ notify_find_server_entry (struct notify *notify, struct server *serv)
|
||||
if (!notify_do_network (notify, serv))
|
||||
return NULL;
|
||||
|
||||
servnot = malloc (sizeof (struct notify_per_server));
|
||||
if (servnot)
|
||||
{
|
||||
memset (servnot, 0, sizeof (struct notify_per_server));
|
||||
servnot->server = serv;
|
||||
servnot->notify = notify;
|
||||
notify->server_list = g_slist_prepend (notify->server_list, servnot);
|
||||
}
|
||||
servnot = g_new0 (struct notify_per_server, 1);
|
||||
servnot->server = serv;
|
||||
servnot->notify = notify;
|
||||
notify->server_list = g_slist_prepend (notify->server_list, servnot);
|
||||
return servnot;
|
||||
}
|
||||
|
||||
@@ -247,10 +243,9 @@ notify_announce_online (server * serv, struct notify_per_server *servnot,
|
||||
|
||||
/* Let's do whois with idle time (like in /quote WHOIS %s %s) */
|
||||
|
||||
char *wii_str = malloc (strlen (nick) * 2 + 2);
|
||||
sprintf (wii_str, "%s %s", nick, nick);
|
||||
char *wii_str = g_strdup_printf ("%s %s", nick, nick);
|
||||
serv->p_whois (serv, wii_str);
|
||||
free (wii_str);
|
||||
g_free (wii_str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -596,14 +591,13 @@ notify_deluser (char *name)
|
||||
servnot = (struct notify_per_server *) notify->server_list->data;
|
||||
notify->server_list =
|
||||
g_slist_remove (notify->server_list, servnot);
|
||||
free (servnot);
|
||||
g_free (servnot);
|
||||
}
|
||||
notify_list = g_slist_remove (notify_list, notify);
|
||||
notify_watch_all (notify, FALSE);
|
||||
if (notify->networks)
|
||||
free (notify->networks);
|
||||
free (notify->name);
|
||||
free (notify);
|
||||
g_free (notify->networks);
|
||||
g_free (notify->name);
|
||||
g_free (notify);
|
||||
fe_notify_update (0);
|
||||
return 1;
|
||||
}
|
||||
@@ -615,27 +609,18 @@ notify_deluser (char *name)
|
||||
void
|
||||
notify_adduser (char *name, char *networks)
|
||||
{
|
||||
struct notify *notify = malloc (sizeof (struct notify));
|
||||
if (notify)
|
||||
{
|
||||
memset (notify, 0, sizeof (struct notify));
|
||||
if (strlen (name) >= NICKLEN)
|
||||
{
|
||||
notify->name = malloc (NICKLEN);
|
||||
safe_strcpy (notify->name, name, NICKLEN);
|
||||
} else
|
||||
{
|
||||
notify->name = strdup (name);
|
||||
}
|
||||
if (networks)
|
||||
notify->networks = despacify_dup (networks);
|
||||
notify->server_list = 0;
|
||||
notify_list = g_slist_prepend (notify_list, notify);
|
||||
notify_checklist ();
|
||||
fe_notify_update (notify->name);
|
||||
fe_notify_update (0);
|
||||
notify_watch_all (notify, TRUE);
|
||||
}
|
||||
struct notify *notify = g_new0 (struct notify, 1);
|
||||
|
||||
notify->name = g_strndup (name, NICKLEN - 1);
|
||||
|
||||
if (networks != NULL)
|
||||
notify->networks = despacify_dup (networks);
|
||||
notify->server_list = 0;
|
||||
notify_list = g_slist_prepend (notify_list, notify);
|
||||
notify_checklist ();
|
||||
fe_notify_update (notify->name);
|
||||
fe_notify_update (0);
|
||||
notify_watch_all (notify, TRUE);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@@ -714,7 +699,7 @@ notify_cleanup ()
|
||||
{
|
||||
notify->server_list =
|
||||
g_slist_remove (notify->server_list, servnot);
|
||||
free (servnot);
|
||||
g_free (servnot);
|
||||
nslist = notify->server_list;
|
||||
} else
|
||||
{
|
||||
|
||||
@@ -90,7 +90,7 @@ random_line (char *file_name)
|
||||
{
|
||||
nofile:
|
||||
/* reason is not a file, an actual reason! */
|
||||
return strdup (file_name);
|
||||
return g_strdup (file_name);
|
||||
}
|
||||
|
||||
/* count number of lines in file */
|
||||
@@ -111,7 +111,7 @@ random_line (char *file_name)
|
||||
}
|
||||
while (lines > ran);
|
||||
fclose (fh);
|
||||
return strdup (buf);
|
||||
return g_strdup (buf);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -121,7 +121,7 @@ server_sendpart (server * serv, char *channel, char *reason)
|
||||
{
|
||||
reason = random_line (prefs.hex_irc_part_reason);
|
||||
serv->p_part (serv, channel, reason);
|
||||
free (reason);
|
||||
g_free (reason);
|
||||
} else
|
||||
{
|
||||
/* reason set by /quit, /close argument */
|
||||
@@ -136,12 +136,12 @@ server_sendquit (session * sess)
|
||||
|
||||
if (!sess->quitreason)
|
||||
{
|
||||
colrea = strdup (prefs.hex_irc_quit_reason);
|
||||
colrea = g_strdup (prefs.hex_irc_quit_reason);
|
||||
check_special_chars (colrea, FALSE);
|
||||
rea = random_line (colrea);
|
||||
free (colrea);
|
||||
g_free (colrea);
|
||||
sess->server->p_quit (sess->server, rea);
|
||||
free (rea);
|
||||
g_free (rea);
|
||||
} else
|
||||
{
|
||||
/* reason set by /quit, /close argument */
|
||||
@@ -269,7 +269,7 @@ cmd_addserver (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
if (!network)
|
||||
{
|
||||
network = servlist_net_add (word[2], "", TRUE);
|
||||
network->encoding = strdup (IRC_DEFAULT_CHARSET);
|
||||
network->encoding = g_strdup (IRC_DEFAULT_CHARSET);
|
||||
}
|
||||
/* if we had the network already, check if the given server already exists */
|
||||
else if (servlist_server_find (network, word_eol[3], NULL))
|
||||
@@ -379,11 +379,10 @@ cmd_away (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
|
||||
if (sess->server->last_away_reason != reason)
|
||||
{
|
||||
if (sess->server->last_away_reason)
|
||||
free (sess->server->last_away_reason);
|
||||
g_free (sess->server->last_away_reason);
|
||||
|
||||
if (reason == word_eol[2])
|
||||
sess->server->last_away_reason = strdup (reason);
|
||||
sess->server->last_away_reason = g_strdup (reason);
|
||||
else
|
||||
sess->server->last_away_reason = reason;
|
||||
}
|
||||
@@ -406,8 +405,7 @@ cmd_back (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
PrintText (sess, _("Already marked back.\n"));
|
||||
}
|
||||
|
||||
if (sess->server->last_away_reason)
|
||||
free (sess->server->last_away_reason);
|
||||
g_free (sess->server->last_away_reason);
|
||||
sess->server->last_away_reason = NULL;
|
||||
|
||||
return TRUE;
|
||||
@@ -1002,14 +1000,14 @@ mdehop_cb (struct User *user, multidata *data)
|
||||
static int
|
||||
cmd_mdehop (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
{
|
||||
char **nicks = malloc (sizeof (char *) * sess->hops);
|
||||
char **nicks = g_new0 (char *, sess->hops);
|
||||
multidata data;
|
||||
|
||||
data.nicks = nicks;
|
||||
data.i = 0;
|
||||
tree_foreach (sess->usertree, (tree_traverse_func *)mdehop_cb, &data);
|
||||
send_channel_modes (sess, tbuf, nicks, 0, data.i, '-', 'h', 0);
|
||||
free (nicks);
|
||||
g_free (nicks);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1028,14 +1026,14 @@ mdeop_cb (struct User *user, multidata *data)
|
||||
static int
|
||||
cmd_mdeop (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
{
|
||||
char **nicks = malloc (sizeof (char *) * sess->ops);
|
||||
char **nicks = g_new0(char *, sess->ops);
|
||||
multidata data;
|
||||
|
||||
data.nicks = nicks;
|
||||
data.i = 0;
|
||||
tree_foreach (sess->usertree, (tree_traverse_func *)mdeop_cb, &data);
|
||||
send_channel_modes (sess, tbuf, nicks, 0, data.i, '-', 'o', 0);
|
||||
free (nicks);
|
||||
g_free (nicks);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1045,18 +1043,13 @@ GSList *menu_list = NULL;
|
||||
static void
|
||||
menu_free (menu_entry *me)
|
||||
{
|
||||
free (me->path);
|
||||
if (me->label)
|
||||
free (me->label);
|
||||
if (me->cmd)
|
||||
free (me->cmd);
|
||||
if (me->ucmd)
|
||||
free (me->ucmd);
|
||||
if (me->group)
|
||||
free (me->group);
|
||||
if (me->icon)
|
||||
free (me->icon);
|
||||
free (me);
|
||||
g_free (me->path);
|
||||
g_free (me->label);
|
||||
g_free (me->cmd);
|
||||
g_free (me->ucmd);
|
||||
g_free (me->group);
|
||||
g_free (me->icon);
|
||||
g_free (me);
|
||||
}
|
||||
|
||||
/* strings equal? but ignore underscores */
|
||||
@@ -1195,7 +1188,7 @@ menu_add (char *path, char *label, char *cmd, char *ucmd, int pos, int state, in
|
||||
return;
|
||||
}
|
||||
|
||||
me = malloc (sizeof (menu_entry));
|
||||
me = g_new (menu_entry, 1);
|
||||
me->pos = pos;
|
||||
me->modifier = mod;
|
||||
me->is_main = menu_is_mainmenu_root (path, &me->root_offset);
|
||||
@@ -1203,31 +1196,26 @@ menu_add (char *path, char *label, char *cmd, char *ucmd, int pos, int state, in
|
||||
me->markup = markup;
|
||||
me->enable = enable;
|
||||
me->key = key;
|
||||
me->path = strdup (path);
|
||||
me->path = g_strdup (path);
|
||||
me->label = NULL;
|
||||
me->cmd = NULL;
|
||||
me->ucmd = NULL;
|
||||
me->group = NULL;
|
||||
me->icon = NULL;
|
||||
|
||||
if (label)
|
||||
me->label = strdup (label);
|
||||
if (cmd)
|
||||
me->cmd = strdup (cmd);
|
||||
if (ucmd)
|
||||
me->ucmd = strdup (ucmd);
|
||||
if (group)
|
||||
me->group = strdup (group);
|
||||
if (icon)
|
||||
me->icon = strdup (icon);
|
||||
me->label = g_strdup (label);
|
||||
me->cmd = g_strdup (cmd);
|
||||
me->ucmd = g_strdup (ucmd);
|
||||
me->group = g_strdup (group);
|
||||
me->icon = g_strdup (icon);
|
||||
|
||||
menu_list = g_slist_append (menu_list, me);
|
||||
label = fe_menu_add (me);
|
||||
if (label)
|
||||
{
|
||||
/* FE has given us a stripped label */
|
||||
free (me->label);
|
||||
me->label = strdup (label);
|
||||
g_free (me->label);
|
||||
me->label = g_strdup (label);
|
||||
g_free (label); /* this is from pango */
|
||||
}
|
||||
}
|
||||
@@ -1456,7 +1444,7 @@ exec_check_process (struct session *sess)
|
||||
{
|
||||
close (sess->running_exec->myfd);
|
||||
fe_input_remove (sess->running_exec->iotag);
|
||||
free (sess->running_exec);
|
||||
g_free (sess->running_exec);
|
||||
sess->running_exec = NULL;
|
||||
}
|
||||
}
|
||||
@@ -1533,11 +1521,10 @@ cmd_execw (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
return FALSE;
|
||||
}
|
||||
len = strlen(word_eol[2]);
|
||||
temp = malloc(len + 2);
|
||||
sprintf(temp, "%s\n", word_eol[2]);
|
||||
temp = g_strconcat (word_eol[2], "\n", NULL);
|
||||
PrintText(sess, temp);
|
||||
write(sess->running_exec->myfd, temp, len + 1);
|
||||
free(temp);
|
||||
g_free(temp);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1561,7 +1548,7 @@ exec_handle_colors (char *buf, int len)
|
||||
if (strchr (buf, 27) == 0)
|
||||
return;
|
||||
|
||||
nbuf = malloc (len + 1);
|
||||
nbuf = g_malloc (len + 1);
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
@@ -1655,7 +1642,7 @@ norm: nbuf[j] = buf[i];
|
||||
|
||||
nbuf[j] = 0;
|
||||
memcpy (buf, nbuf, j + 1);
|
||||
free (nbuf);
|
||||
g_free (nbuf);
|
||||
}
|
||||
|
||||
#ifndef HAVE_MEMRCHR
|
||||
@@ -1681,14 +1668,14 @@ exec_data (GIOChannel *source, GIOCondition condition, struct nbexec *s)
|
||||
len = s->buffill;
|
||||
if (len) {
|
||||
/* append new data to buffered incomplete line */
|
||||
buf = malloc(len + 2050);
|
||||
buf = g_malloc (len + 2050);
|
||||
memcpy(buf, s->linebuf, len);
|
||||
readpos = buf + len;
|
||||
free(s->linebuf);
|
||||
g_free (s->linebuf);
|
||||
s->linebuf = NULL;
|
||||
}
|
||||
else
|
||||
readpos = buf = malloc(2050);
|
||||
readpos = buf = g_malloc (2050);
|
||||
|
||||
rd = read (sok, readpos, 2048);
|
||||
if (rd < 1)
|
||||
@@ -1709,12 +1696,12 @@ exec_data (GIOChannel *source, GIOCondition condition, struct nbexec *s)
|
||||
else
|
||||
PrintText (s->sess, buf);
|
||||
}
|
||||
free(buf);
|
||||
g_free(buf);
|
||||
waitpid (s->childpid, NULL, 0);
|
||||
s->sess->running_exec = NULL;
|
||||
fe_input_remove (s->iotag);
|
||||
close (sok);
|
||||
free (s);
|
||||
g_free (s);
|
||||
return TRUE;
|
||||
}
|
||||
len += rd;
|
||||
@@ -1727,7 +1714,7 @@ exec_data (GIOChannel *source, GIOCondition condition, struct nbexec *s)
|
||||
rest = buf;
|
||||
if (*rest) {
|
||||
s->buffill = len - (rest - buf); /* = strlen(rest) */
|
||||
s->linebuf = malloc(s->buffill + 1);
|
||||
s->linebuf = g_malloc (s->buffill + 1);
|
||||
memcpy(s->linebuf, rest, s->buffill);
|
||||
*rest = '\0';
|
||||
len -= s->buffill; /* possibly 0 */
|
||||
@@ -1743,7 +1730,7 @@ exec_data (GIOChannel *source, GIOCondition condition, struct nbexec *s)
|
||||
PrintText (s->sess, buf);
|
||||
}
|
||||
|
||||
free(buf);
|
||||
g_free (buf);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1805,8 +1792,7 @@ cmd_exec (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
s = (struct nbexec *) malloc (sizeof (struct nbexec));
|
||||
memset(s, 0, sizeof(*s));
|
||||
s = g_new0 (struct nbexec, 1);
|
||||
s->myfd = fds[0];
|
||||
s->tochannel = tochannel;
|
||||
s->sess = sess;
|
||||
@@ -1853,8 +1839,9 @@ cmd_exec (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
PrintText (sess, "Error in fork(2)\n");
|
||||
close(fds[0]);
|
||||
close(fds[1]);
|
||||
free (s);
|
||||
} else
|
||||
g_free (s);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Parent path */
|
||||
close(fds[1]);
|
||||
@@ -1946,8 +1933,8 @@ get_bool_cb (int val, getvalinfo *info)
|
||||
if (is_session (info->sess))
|
||||
handle_command (info->sess, buf, FALSE);
|
||||
|
||||
free (info->cmd);
|
||||
free (info);
|
||||
g_free (info->cmd);
|
||||
g_free (info);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -1958,8 +1945,8 @@ cmd_getbool (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
if (!word[4][0])
|
||||
return FALSE;
|
||||
|
||||
info = malloc (sizeof (*info));
|
||||
info->cmd = strdup (word[2]);
|
||||
info = g_new (getvalinfo, 1);
|
||||
info->cmd = g_strdup (word[2]);
|
||||
info->sess = sess;
|
||||
|
||||
fe_get_bool (word[3], word_eol[4], get_bool_cb, info);
|
||||
@@ -1979,8 +1966,8 @@ get_int_cb (int cancel, int val, getvalinfo *info)
|
||||
handle_command (info->sess, buf, FALSE);
|
||||
}
|
||||
|
||||
free (info->cmd);
|
||||
free (info);
|
||||
g_free (info->cmd);
|
||||
g_free (info);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -1991,8 +1978,8 @@ cmd_getint (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
if (!word[4][0])
|
||||
return FALSE;
|
||||
|
||||
info = malloc (sizeof (*info));
|
||||
info->cmd = strdup (word[3]);
|
||||
info = g_new (getvalinfo, 1);
|
||||
info->cmd = g_strdup (word[3]);
|
||||
info->sess = sess;
|
||||
|
||||
fe_get_int (word[4], atoi (word[2]), get_int_cb, info);
|
||||
@@ -2015,7 +2002,7 @@ get_file_cb (char *cmd, char *file)
|
||||
else
|
||||
{
|
||||
handle_command (current_sess, cmd, FALSE);
|
||||
free (cmd);
|
||||
g_free (cmd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2046,7 +2033,7 @@ cmd_getfile (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
idx++;
|
||||
}
|
||||
|
||||
fe_get_file (word[idx+1], word[idx+2], (void *)get_file_cb, strdup (word[idx]), flags);
|
||||
fe_get_file (word[idx+1], word[idx+2], (void *)get_file_cb, g_strdup (word[idx]), flags);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -2063,8 +2050,8 @@ get_str_cb (int cancel, char *val, getvalinfo *info)
|
||||
handle_command (info->sess, buf, FALSE);
|
||||
}
|
||||
|
||||
free (info->cmd);
|
||||
free (info);
|
||||
g_free (info->cmd);
|
||||
g_free (info);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -2075,8 +2062,8 @@ cmd_getstr (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
if (!word[4][0])
|
||||
return FALSE;
|
||||
|
||||
info = malloc (sizeof (*info));
|
||||
info->cmd = strdup (word[3]);
|
||||
info = g_new (getvalinfo, 1);
|
||||
info->cmd = g_strdup (word[3]);
|
||||
info->sess = sess;
|
||||
|
||||
fe_get_str (word[4], word[2], get_str_cb, info);
|
||||
@@ -2202,7 +2189,7 @@ cmd_help (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
} else
|
||||
{
|
||||
struct popup *pop;
|
||||
char *buf = malloc (4096);
|
||||
char *buf = g_malloc (4096);
|
||||
help_list hl;
|
||||
|
||||
hl.longfmt = longfmt;
|
||||
@@ -2247,7 +2234,7 @@ cmd_help (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
plugin_command_foreach (sess, &hl, (void *)show_help_line);
|
||||
strcat (buf, "\n");
|
||||
PrintText (sess, buf);
|
||||
free (buf);
|
||||
g_free (buf);
|
||||
|
||||
PrintTextf (sess, "\n%s\n\n", _("Type /HELP <command> for more information, or /HELP -l"));
|
||||
}
|
||||
@@ -2723,7 +2710,7 @@ mop_cb (struct User *user, multidata *data)
|
||||
static int
|
||||
cmd_mop (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
{
|
||||
char **nicks = malloc (sizeof (char *) * (sess->total - sess->ops));
|
||||
char **nicks = g_new0 (char *, sess->total - sess->ops);
|
||||
multidata data;
|
||||
|
||||
data.nicks = nicks;
|
||||
@@ -2731,7 +2718,7 @@ cmd_mop (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
tree_foreach (sess->usertree, (tree_traverse_func *)mop_cb, &data);
|
||||
send_channel_modes (sess, tbuf, nicks, 0, data.i, '+', 'o', 0);
|
||||
|
||||
free (nicks);
|
||||
g_free (nicks);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -4313,81 +4300,78 @@ check_special_chars (char *cmd, int do_ascii) /* check for %X */
|
||||
if (!len)
|
||||
return;
|
||||
|
||||
buf = malloc (len + 1);
|
||||
buf = g_malloc (len + 1);
|
||||
|
||||
if (buf)
|
||||
while (cmd[j])
|
||||
{
|
||||
while (cmd[j])
|
||||
switch (cmd[j])
|
||||
{
|
||||
switch (cmd[j])
|
||||
case '%':
|
||||
occur++;
|
||||
if ( do_ascii &&
|
||||
j + 3 < len &&
|
||||
(isdigit ((unsigned char) cmd[j + 1]) && isdigit ((unsigned char) cmd[j + 2]) &&
|
||||
isdigit ((unsigned char) cmd[j + 3])))
|
||||
{
|
||||
case '%':
|
||||
occur++;
|
||||
if ( do_ascii &&
|
||||
j + 3 < len &&
|
||||
(isdigit ((unsigned char) cmd[j + 1]) && isdigit ((unsigned char) cmd[j + 2]) &&
|
||||
isdigit ((unsigned char) cmd[j + 3])))
|
||||
tbuf[0] = cmd[j + 1];
|
||||
tbuf[1] = cmd[j + 2];
|
||||
tbuf[2] = cmd[j + 3];
|
||||
tbuf[3] = 0;
|
||||
buf[i] = atoi (tbuf);
|
||||
utf = g_locale_to_utf8 (buf + i, 1, 0, &utf_len, 0);
|
||||
if (utf)
|
||||
{
|
||||
tbuf[0] = cmd[j + 1];
|
||||
tbuf[1] = cmd[j + 2];
|
||||
tbuf[2] = cmd[j + 3];
|
||||
tbuf[3] = 0;
|
||||
buf[i] = atoi (tbuf);
|
||||
utf = g_locale_to_utf8 (buf + i, 1, 0, &utf_len, 0);
|
||||
if (utf)
|
||||
{
|
||||
memcpy (buf + i, utf, utf_len);
|
||||
g_free (utf);
|
||||
i += (utf_len - 1);
|
||||
}
|
||||
j += 3;
|
||||
} else
|
||||
{
|
||||
switch (cmd[j + 1])
|
||||
{
|
||||
case 'R':
|
||||
buf[i] = '\026';
|
||||
break;
|
||||
case 'U':
|
||||
buf[i] = '\037';
|
||||
break;
|
||||
case 'B':
|
||||
buf[i] = '\002';
|
||||
break;
|
||||
case 'I':
|
||||
buf[i] = '\035';
|
||||
break;
|
||||
case 'C':
|
||||
buf[i] = '\003';
|
||||
break;
|
||||
case 'O':
|
||||
buf[i] = '\017';
|
||||
break;
|
||||
case 'H': /* CL: invisible text code */
|
||||
buf[i] = HIDDEN_CHAR;
|
||||
break;
|
||||
case '%':
|
||||
buf[i] = '%';
|
||||
break;
|
||||
default:
|
||||
buf[i] = '%';
|
||||
j--;
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
break;
|
||||
default:
|
||||
buf[i] = cmd[j];
|
||||
memcpy (buf + i, utf, utf_len);
|
||||
g_free (utf);
|
||||
i += (utf_len - 1);
|
||||
}
|
||||
j += 3;
|
||||
} else
|
||||
{
|
||||
switch (cmd[j + 1])
|
||||
{
|
||||
case 'R':
|
||||
buf[i] = '\026';
|
||||
break;
|
||||
case 'U':
|
||||
buf[i] = '\037';
|
||||
break;
|
||||
case 'B':
|
||||
buf[i] = '\002';
|
||||
break;
|
||||
case 'I':
|
||||
buf[i] = '\035';
|
||||
break;
|
||||
case 'C':
|
||||
buf[i] = '\003';
|
||||
break;
|
||||
case 'O':
|
||||
buf[i] = '\017';
|
||||
break;
|
||||
case 'H': /* CL: invisible text code */
|
||||
buf[i] = HIDDEN_CHAR;
|
||||
break;
|
||||
case '%':
|
||||
buf[i] = '%';
|
||||
break;
|
||||
default:
|
||||
buf[i] = '%';
|
||||
j--;
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
break;
|
||||
default:
|
||||
buf[i] = cmd[j];
|
||||
}
|
||||
j++;
|
||||
i++;
|
||||
}
|
||||
buf[i] = 0;
|
||||
if (occur)
|
||||
strcpy (cmd, buf);
|
||||
free (buf);
|
||||
j++;
|
||||
i++;
|
||||
}
|
||||
buf[i] = 0;
|
||||
if (occur)
|
||||
strcpy (cmd, buf);
|
||||
g_free (buf);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
@@ -4487,12 +4471,10 @@ handle_say (session *sess, char *text, int check_spch)
|
||||
struct DCC *dcc;
|
||||
char *word[PDIWORDS+1];
|
||||
char *word_eol[PDIWORDS+1];
|
||||
char pdibuf_static[1024];
|
||||
char newcmd_static[1024];
|
||||
char *pdibuf = pdibuf_static;
|
||||
char *newcmd = newcmd_static;
|
||||
char *pdibuf;
|
||||
char *newcmd;
|
||||
int len;
|
||||
int newcmdlen = sizeof newcmd_static;
|
||||
int newcmdlen;
|
||||
message_tags_data no_tags = MESSAGE_TAGS_DATA_INIT;
|
||||
|
||||
if (strcmp (sess->channel, "(lastlog)") == 0)
|
||||
@@ -4502,11 +4484,9 @@ handle_say (session *sess, char *text, int check_spch)
|
||||
}
|
||||
|
||||
len = strlen (text);
|
||||
if (len >= sizeof pdibuf_static)
|
||||
pdibuf = malloc (len + 1);
|
||||
|
||||
if (len + NICKLEN >= newcmdlen)
|
||||
newcmd = malloc (newcmdlen = len + NICKLEN + 1);
|
||||
pdibuf = g_malloc (len + 1);
|
||||
newcmdlen = MAX(len + NICKLEN + 1, TBUFSIZE);
|
||||
newcmd = g_malloc (newcmdlen);
|
||||
|
||||
if (check_spch && prefs.hex_input_perc_color)
|
||||
check_special_chars (text, prefs.hex_input_perc_ascii);
|
||||
@@ -4579,11 +4559,9 @@ handle_say (session *sess, char *text, int check_spch)
|
||||
}
|
||||
|
||||
xit:
|
||||
if (pdibuf != pdibuf_static)
|
||||
free (pdibuf);
|
||||
g_free (pdibuf);
|
||||
|
||||
if (newcmd != newcmd_static)
|
||||
free (newcmd);
|
||||
g_free (newcmd);
|
||||
}
|
||||
|
||||
char *
|
||||
@@ -4677,8 +4655,6 @@ handle_command (session *sess, char *cmd, int check_spch)
|
||||
char *word_eol[PDIWORDS+1];
|
||||
static int command_level = 0;
|
||||
struct commands *int_cmd;
|
||||
char pdibuf_static[1024];
|
||||
char tbuf_static[TBUFSIZE];
|
||||
char *pdibuf;
|
||||
char *tbuf;
|
||||
int len;
|
||||
@@ -4693,23 +4669,8 @@ handle_command (session *sess, char *cmd, int check_spch)
|
||||
/* anything below MUST DEC command_level before returning */
|
||||
|
||||
len = strlen (cmd);
|
||||
if (len >= sizeof (pdibuf_static))
|
||||
{
|
||||
pdibuf = malloc (len + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
pdibuf = pdibuf_static;
|
||||
}
|
||||
|
||||
if ((len * 2) >= sizeof (tbuf_static))
|
||||
{
|
||||
tbuf = malloc ((len * 2) + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
tbuf = tbuf_static;
|
||||
}
|
||||
pdibuf = g_malloc (len + 1);
|
||||
tbuf = g_malloc (MAX(TBUFSIZE, (len * 2) + 1));
|
||||
|
||||
/* split the text into words and word_eol */
|
||||
process_data_init (pdibuf, cmd, word, word_eol, TRUE, TRUE);
|
||||
@@ -4802,15 +4763,8 @@ handle_command (session *sess, char *cmd, int check_spch)
|
||||
xit:
|
||||
command_level--;
|
||||
|
||||
if (pdibuf != pdibuf_static)
|
||||
{
|
||||
free (pdibuf);
|
||||
}
|
||||
|
||||
if (tbuf != tbuf_static)
|
||||
{
|
||||
free (tbuf);
|
||||
}
|
||||
g_free (pdibuf);
|
||||
g_free (tbuf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -53,9 +53,9 @@ static void
|
||||
timer_del (timer *tim)
|
||||
{
|
||||
timer_list = g_slist_remove (timer_list, tim);
|
||||
free (tim->command);
|
||||
g_free (tim->command);
|
||||
hexchat_unhook (ph, tim->hook);
|
||||
free (tim);
|
||||
g_free (tim);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -119,11 +119,11 @@ timer_add (int ref, int timeout, int repeat, char *command)
|
||||
}
|
||||
}
|
||||
|
||||
tim = malloc (sizeof (timer));
|
||||
tim = g_new (timer, 1);
|
||||
tim->ref = ref;
|
||||
tim->repeat = repeat;
|
||||
tim->timeout = timeout;
|
||||
tim->command = strdup (command);
|
||||
tim->command = g_strdup (command);
|
||||
tim->context = hexchat_get_context (ph);
|
||||
tim->forever = FALSE;
|
||||
|
||||
|
||||
@@ -161,16 +161,12 @@ plugin_free (hexchat_plugin *pl, int do_deinit, int allow_refuse)
|
||||
xit:
|
||||
if (pl->free_strings)
|
||||
{
|
||||
if (pl->name)
|
||||
free (pl->name);
|
||||
if (pl->desc)
|
||||
free (pl->desc);
|
||||
if (pl->version)
|
||||
free (pl->version);
|
||||
g_free (pl->name);
|
||||
g_free (pl->desc);
|
||||
g_free (pl->version);
|
||||
}
|
||||
if (pl->filename)
|
||||
free ((char *)pl->filename);
|
||||
free (pl);
|
||||
g_free ((char *)pl->filename);
|
||||
g_free (pl);
|
||||
|
||||
plugin_list = g_slist_remove (plugin_list, pl);
|
||||
|
||||
@@ -188,7 +184,7 @@ plugin_list_add (hexchat_context *ctx, char *filename, const char *name,
|
||||
{
|
||||
hexchat_plugin *pl;
|
||||
|
||||
pl = malloc (sizeof (hexchat_plugin));
|
||||
pl = g_new (hexchat_plugin, 1);
|
||||
pl->handle = handle;
|
||||
pl->filename = filename;
|
||||
pl->context = ctx;
|
||||
@@ -239,9 +235,7 @@ plugin_add (session *sess, char *filename, void *handle, void *init_func,
|
||||
hexchat_plugin *pl;
|
||||
char *file;
|
||||
|
||||
file = NULL;
|
||||
if (filename)
|
||||
file = strdup (filename);
|
||||
file = g_strdup (filename);
|
||||
|
||||
pl = plugin_list_add (sess, file, file, NULL, NULL, handle, deinit_func,
|
||||
fake, FALSE);
|
||||
@@ -596,7 +590,7 @@ xit:
|
||||
if (!hook || hook->type == HOOK_DELETED)
|
||||
{
|
||||
hook_list = g_slist_remove (hook_list, hook);
|
||||
free (hook);
|
||||
g_free (hook);
|
||||
}
|
||||
list = next;
|
||||
}
|
||||
@@ -615,13 +609,7 @@ plugin_emit_command (session *sess, char *name, char *word[], char *word_eol[])
|
||||
hexchat_event_attrs *
|
||||
hexchat_event_attrs_create (hexchat_plugin *ph)
|
||||
{
|
||||
hexchat_event_attrs *attrs;
|
||||
|
||||
attrs = g_malloc (sizeof (*attrs));
|
||||
|
||||
attrs->server_time_utc = (time_t) 0;
|
||||
|
||||
return attrs;
|
||||
return g_new0 (hexchat_event_attrs, 1);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -796,15 +784,11 @@ plugin_add_hook (hexchat_plugin *pl, int type, int pri, const char *name,
|
||||
{
|
||||
hexchat_hook *hook;
|
||||
|
||||
hook = malloc (sizeof (hexchat_hook));
|
||||
memset (hook, 0, sizeof (hexchat_hook));
|
||||
|
||||
hook = g_new0 (hexchat_hook, 1);
|
||||
hook->type = type;
|
||||
hook->pri = pri;
|
||||
if (name)
|
||||
hook->name = strdup (name);
|
||||
if (help_text)
|
||||
hook->help_text = strdup (help_text);
|
||||
hook->name = g_strdup (name);
|
||||
hook->help_text = g_strdup (help_text);
|
||||
hook->callback = callb;
|
||||
hook->pl = pl;
|
||||
hook->userdata = userdata;
|
||||
@@ -892,10 +876,8 @@ hexchat_unhook (hexchat_plugin *ph, hexchat_hook *hook)
|
||||
|
||||
hook->type = HOOK_DELETED; /* expunge later */
|
||||
|
||||
if (hook->name)
|
||||
free (hook->name); /* NULL for timers & fds */
|
||||
if (hook->help_text)
|
||||
free (hook->help_text); /* NULL for non-commands */
|
||||
g_free (hook->name); /* NULL for timers & fds */
|
||||
g_free (hook->help_text); /* NULL for non-commands */
|
||||
|
||||
return hook->userdata;
|
||||
}
|
||||
@@ -1263,8 +1245,7 @@ hexchat_list_get (hexchat_plugin *ph, const char *name)
|
||||
{
|
||||
hexchat_list *list;
|
||||
|
||||
list = malloc (sizeof (hexchat_list));
|
||||
list->pos = NULL;
|
||||
list = g_new0 (hexchat_list, 1);
|
||||
|
||||
switch (str_hash (name))
|
||||
{
|
||||
@@ -1299,7 +1280,7 @@ hexchat_list_get (hexchat_plugin *ph, const char *name)
|
||||
} /* fall through */
|
||||
|
||||
default:
|
||||
free (list);
|
||||
g_free (list);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1311,7 +1292,7 @@ hexchat_list_free (hexchat_plugin *ph, hexchat_list *xlist)
|
||||
{
|
||||
if (xlist->type == LIST_USERS)
|
||||
g_slist_free (xlist->head);
|
||||
free (xlist);
|
||||
g_free (xlist);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -1651,8 +1632,8 @@ hexchat_plugingui_add (hexchat_plugin *ph, const char *filename,
|
||||
const char *version, char *reserved)
|
||||
{
|
||||
#ifdef USE_PLUGIN
|
||||
ph = plugin_list_add (NULL, strdup (filename), strdup (name), strdup (desc),
|
||||
strdup (version), NULL, NULL, TRUE, TRUE);
|
||||
ph = plugin_list_add (NULL, g_strdup (filename), g_strdup (name), g_strdup (desc),
|
||||
g_strdup (version), NULL, NULL, TRUE, TRUE);
|
||||
fe_pluginlist_update ();
|
||||
#endif
|
||||
|
||||
@@ -1917,7 +1898,6 @@ hexchat_pluginpref_get_str_real (hexchat_plugin *pl, const char *var, char *dest
|
||||
g_free (confname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_free (confname);
|
||||
|
||||
if (!cfg_get_str (cfg, var, buf, sizeof(buf)))
|
||||
|
||||
@@ -1481,13 +1481,10 @@ irc_inline (server *serv, char *buf, int len)
|
||||
char *type, *text;
|
||||
char *word[PDIWORDS+1];
|
||||
char *word_eol[PDIWORDS+1];
|
||||
char pdibuf_static[522]; /* 1 line can potentially be 512*6 in utf8 */
|
||||
char *pdibuf = pdibuf_static;
|
||||
char *pdibuf;
|
||||
message_tags_data tags_data = MESSAGE_TAGS_DATA_INIT;
|
||||
|
||||
/* need more than 522? fall back to malloc */
|
||||
if (len >= sizeof (pdibuf_static))
|
||||
pdibuf = malloc (len + 1);
|
||||
pdibuf = g_malloc (len + 1);
|
||||
|
||||
sess = serv->front_session;
|
||||
|
||||
@@ -1566,8 +1563,7 @@ irc_inline (server *serv, char *buf, int len)
|
||||
}
|
||||
|
||||
xit:
|
||||
if (pdibuf != pdibuf_static)
|
||||
free (pdibuf);
|
||||
g_free (pdibuf);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -212,7 +212,7 @@ tcp_send_queue (server *serv)
|
||||
|
||||
buf--;
|
||||
serv->outbound_queue = g_slist_remove (serv->outbound_queue, buf);
|
||||
free (buf);
|
||||
g_free (buf);
|
||||
list = serv->outbound_queue;
|
||||
} else
|
||||
{
|
||||
@@ -234,7 +234,7 @@ tcp_send_len (server *serv, char *buf, int len)
|
||||
if (!prefs.hex_net_throttle)
|
||||
return server_send_real (serv, buf, len);
|
||||
|
||||
dbuf = malloc (len + 2); /* first byte is the priority */
|
||||
dbuf = g_malloc (len + 2); /* first byte is the priority */
|
||||
dbuf[0] = 2; /* pri 2 for most things */
|
||||
memcpy (dbuf + 1, buf, len);
|
||||
dbuf[len + 1] = 0;
|
||||
@@ -527,7 +527,7 @@ server_close_pipe (int *pipefd) /* see comments below */
|
||||
{
|
||||
close (pipefd[0]); /* close WRITE end first to cause an EOF on READ */
|
||||
close (pipefd[1]); /* in giowin32, and end that thread. */
|
||||
free (pipefd);
|
||||
g_free (pipefd);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -560,7 +560,7 @@ server_stopconnecting (server * serv)
|
||||
|
||||
{
|
||||
/* if we close the pipe now, giowin32 will crash. */
|
||||
int *pipefd = malloc (sizeof (int) * 2);
|
||||
int *pipefd = g_new (int, 2);
|
||||
pipefd[0] = serv->childwrite;
|
||||
pipefd[1] = serv->childread;
|
||||
g_idle_add ((GSourceFunc)server_close_pipe, pipefd);
|
||||
@@ -1282,7 +1282,7 @@ traverse_socks5 (int print_fd, int sok, char *serverAddr, int port)
|
||||
|
||||
addrlen = strlen (serverAddr);
|
||||
packetlen = 4 + 1 + addrlen + 2;
|
||||
sc2 = malloc (packetlen);
|
||||
sc2 = g_malloc (packetlen);
|
||||
sc2[0] = 5; /* version */
|
||||
sc2[1] = 1; /* command */
|
||||
sc2[2] = 0; /* reserved */
|
||||
@@ -1291,7 +1291,7 @@ traverse_socks5 (int print_fd, int sok, char *serverAddr, int port)
|
||||
memcpy (sc2 + 5, serverAddr, addrlen);
|
||||
*((unsigned short *) (sc2 + 5 + addrlen)) = htons (port);
|
||||
send (sok, sc2, packetlen, 0);
|
||||
free (sc2);
|
||||
g_free (sc2);
|
||||
|
||||
/* consume all of the reply */
|
||||
if (recv (sok, buf, 4, 0) != 4)
|
||||
@@ -1542,7 +1542,7 @@ server_child (server * serv)
|
||||
if (proxy_type) {
|
||||
char *c;
|
||||
c = strchr (proxy, ':') + 3;
|
||||
proxy_host = strdup (c);
|
||||
proxy_host = g_strdup (c);
|
||||
c = strchr (proxy_host, ':');
|
||||
*c = '\0';
|
||||
proxy_port = atoi (c + 1);
|
||||
@@ -1557,7 +1557,7 @@ server_child (server * serv)
|
||||
prefs.hex_net_proxy_use != 2) /* proxy is NOT dcc-only */
|
||||
{
|
||||
proxy_type = prefs.hex_net_proxy_type;
|
||||
proxy_host = strdup (prefs.hex_net_proxy_host);
|
||||
proxy_host = g_strdup (prefs.hex_net_proxy_host);
|
||||
proxy_port = prefs.hex_net_proxy_port;
|
||||
}
|
||||
}
|
||||
@@ -1570,7 +1570,7 @@ server_child (server * serv)
|
||||
snprintf (buf, sizeof (buf), "9\n%s\n", proxy_host);
|
||||
write (serv->childwrite, buf, strlen (buf));
|
||||
ip = net_resolve (ns_server, proxy_host, proxy_port, &real_hostname);
|
||||
free (proxy_host);
|
||||
g_free (proxy_host);
|
||||
if (!ip)
|
||||
{
|
||||
write (serv->childwrite, "1\n", 2);
|
||||
@@ -1589,7 +1589,7 @@ server_child (server * serv)
|
||||
goto xit;
|
||||
}
|
||||
} else /* otherwise we can just use the hostname */
|
||||
proxy_ip = strdup (hostname);
|
||||
proxy_ip = g_strdup (hostname);
|
||||
} else
|
||||
{
|
||||
ip = net_resolve (ns_server, hostname, port, &real_hostname);
|
||||
@@ -1657,12 +1657,9 @@ xit:
|
||||
/* no need to free ip/real_hostname, this process is exiting */
|
||||
#ifdef WIN32
|
||||
/* under win32 we use a thread -> shared memory, must free! */
|
||||
if (proxy_ip)
|
||||
free (proxy_ip);
|
||||
if (ip)
|
||||
free (ip);
|
||||
if (real_hostname)
|
||||
free (real_hostname);
|
||||
g_free (proxy_ip);
|
||||
g_free (ip);
|
||||
g_free (real_hostname);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
@@ -1827,7 +1824,7 @@ server_set_encoding (server *serv, char *new_encoding)
|
||||
|
||||
if (serv->encoding)
|
||||
{
|
||||
free (serv->encoding);
|
||||
g_free (serv->encoding);
|
||||
/* can be left as NULL to indicate system encoding */
|
||||
serv->encoding = NULL;
|
||||
serv->using_cp1255 = FALSE;
|
||||
@@ -1836,7 +1833,7 @@ server_set_encoding (server *serv, char *new_encoding)
|
||||
|
||||
if (new_encoding)
|
||||
{
|
||||
serv->encoding = strdup (new_encoding);
|
||||
serv->encoding = g_strdup (new_encoding);
|
||||
/* the serverlist GUI might have added a space
|
||||
and short description - remove it. */
|
||||
space = strchr (serv->encoding, ' ');
|
||||
@@ -1858,8 +1855,7 @@ server_new (void)
|
||||
static int id = 0;
|
||||
server *serv;
|
||||
|
||||
serv = malloc (sizeof (struct server));
|
||||
memset (serv, 0, sizeof (struct server));
|
||||
serv = g_new0 (struct server, 1);
|
||||
|
||||
/* use server.c and proto-irc.c functions */
|
||||
server_fill_her_up (serv);
|
||||
@@ -1885,19 +1881,15 @@ is_server (server *serv)
|
||||
void
|
||||
server_set_defaults (server *serv)
|
||||
{
|
||||
if (serv->chantypes)
|
||||
free (serv->chantypes);
|
||||
if (serv->chanmodes)
|
||||
free (serv->chanmodes);
|
||||
if (serv->nick_prefixes)
|
||||
free (serv->nick_prefixes);
|
||||
if (serv->nick_modes)
|
||||
free (serv->nick_modes);
|
||||
g_free (serv->chantypes);
|
||||
g_free (serv->chanmodes);
|
||||
g_free (serv->nick_prefixes);
|
||||
g_free (serv->nick_modes);
|
||||
|
||||
serv->chantypes = strdup ("#&!+");
|
||||
serv->chanmodes = strdup ("beI,k,l");
|
||||
serv->nick_prefixes = strdup ("@%+");
|
||||
serv->nick_modes = strdup ("ohv");
|
||||
serv->chantypes = g_strdup ("#&!+");
|
||||
serv->chanmodes = g_strdup ("beI,k,l");
|
||||
serv->nick_prefixes = g_strdup ("@%+");
|
||||
serv->nick_modes = g_strdup ("ohv");
|
||||
|
||||
serv->nickcount = 1;
|
||||
serv->end_of_motd = FALSE;
|
||||
@@ -2001,9 +1993,8 @@ server_away_free_messages (server *serv)
|
||||
if (away->server == serv)
|
||||
{
|
||||
away_list = g_slist_remove (away_list, away);
|
||||
if (away->message)
|
||||
free (away->message);
|
||||
free (away);
|
||||
g_free (away->message);
|
||||
g_free (away);
|
||||
next = away_list;
|
||||
}
|
||||
list = next;
|
||||
@@ -2017,20 +2008,17 @@ server_away_save_message (server *serv, char *nick, char *msg)
|
||||
|
||||
if (away) /* Change message for known user */
|
||||
{
|
||||
if (away->message)
|
||||
free (away->message);
|
||||
away->message = strdup (msg);
|
||||
} else
|
||||
/* Create brand new entry */
|
||||
g_free (away->message);
|
||||
away->message = g_strdup (msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
away = malloc (sizeof (struct away_msg));
|
||||
if (away)
|
||||
{
|
||||
away->server = serv;
|
||||
safe_strcpy (away->nick, nick, sizeof (away->nick));
|
||||
away->message = strdup (msg);
|
||||
away_list = g_slist_prepend (away_list, away);
|
||||
}
|
||||
/* Create brand new entry */
|
||||
away = g_new(struct away_msg, 1);
|
||||
away->server = serv;
|
||||
safe_strcpy (away->nick, nick, sizeof (away->nick));
|
||||
away->message = g_strdup (msg);
|
||||
away_list = g_slist_prepend (away_list, away);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2045,16 +2033,13 @@ server_free (server *serv)
|
||||
serv->flush_queue (serv);
|
||||
server_away_free_messages (serv);
|
||||
|
||||
free (serv->nick_modes);
|
||||
free (serv->nick_prefixes);
|
||||
free (serv->chanmodes);
|
||||
free (serv->chantypes);
|
||||
if (serv->bad_nick_prefixes)
|
||||
free (serv->bad_nick_prefixes);
|
||||
if (serv->last_away_reason)
|
||||
free (serv->last_away_reason);
|
||||
if (serv->encoding)
|
||||
free (serv->encoding);
|
||||
g_free (serv->nick_modes);
|
||||
g_free (serv->nick_prefixes);
|
||||
g_free (serv->chanmodes);
|
||||
g_free (serv->chantypes);
|
||||
g_free (serv->bad_nick_prefixes);
|
||||
g_free (serv->last_away_reason);
|
||||
g_free (serv->encoding);
|
||||
if (serv->favlist)
|
||||
g_slist_free_full (serv->favlist, (GDestroyNotify) servlist_favchan_free);
|
||||
#ifdef USE_OPENSSL
|
||||
@@ -2064,7 +2049,7 @@ server_free (server *serv)
|
||||
|
||||
fe_server_callback (serv);
|
||||
|
||||
free (serv);
|
||||
g_free (serv);
|
||||
|
||||
notify_cleanup ();
|
||||
}
|
||||
|
||||
@@ -566,9 +566,7 @@ servlist_favchan_copy (favchannel *fav)
|
||||
{
|
||||
favchannel *newfav;
|
||||
|
||||
newfav = malloc (sizeof (favchannel));
|
||||
memset (newfav, 0, sizeof (favchannel));
|
||||
|
||||
newfav = g_new (favchannel, 1);
|
||||
newfav->name = g_strdup (fav->name);
|
||||
newfav->key = g_strdup (fav->key); /* g_strdup() can handle NULLs so no need to check it */
|
||||
|
||||
@@ -924,9 +922,8 @@ servlist_server_add (ircnet *net, char *name)
|
||||
{
|
||||
ircserver *serv;
|
||||
|
||||
serv = malloc (sizeof (ircserver));
|
||||
memset (serv, 0, sizeof (ircserver));
|
||||
serv->hostname = strdup (name);
|
||||
serv = g_new (ircserver, 1);
|
||||
serv->hostname = g_strdup (name);
|
||||
|
||||
net->servlist = g_slist_append (net->servlist, serv);
|
||||
|
||||
@@ -938,9 +935,8 @@ servlist_command_add (ircnet *net, char *cmd)
|
||||
{
|
||||
commandentry *entry;
|
||||
|
||||
entry = malloc (sizeof (commandentry));
|
||||
memset (entry, 0, sizeof (commandentry));
|
||||
entry->command = strdup (cmd);
|
||||
entry = g_new (commandentry, 1);
|
||||
entry->command = g_strdup (cmd);
|
||||
|
||||
net->commandlist = g_slist_append (net->commandlist, entry);
|
||||
|
||||
@@ -952,9 +948,7 @@ servlist_favchan_listadd (GSList *chanlist, char *channel, char *key)
|
||||
{
|
||||
favchannel *chan;
|
||||
|
||||
chan = malloc (sizeof (favchannel));
|
||||
memset (chan, 0, sizeof (favchannel));
|
||||
|
||||
chan = g_new (favchannel, 1);
|
||||
chan->name = g_strdup (channel);
|
||||
chan->key = g_strdup (key);
|
||||
chanlist = g_slist_append (chanlist, chan);
|
||||
@@ -990,8 +984,8 @@ servlist_favchan_add (ircnet *net, char *channel)
|
||||
void
|
||||
servlist_server_remove (ircnet *net, ircserver *serv)
|
||||
{
|
||||
free (serv->hostname);
|
||||
free (serv);
|
||||
g_free (serv->hostname);
|
||||
g_free (serv);
|
||||
net->servlist = g_slist_remove (net->servlist, serv);
|
||||
}
|
||||
|
||||
@@ -1044,7 +1038,7 @@ free_and_clear (char *str)
|
||||
char *orig = str;
|
||||
while (*str)
|
||||
*str++ = 0;
|
||||
free (orig);
|
||||
g_free (orig);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1072,25 +1066,18 @@ servlist_net_remove (ircnet *net)
|
||||
servlist_server_remove_all (net);
|
||||
network_list = g_slist_remove (network_list, net);
|
||||
|
||||
if (net->nick)
|
||||
free (net->nick);
|
||||
if (net->nick2)
|
||||
free (net->nick2);
|
||||
if (net->user)
|
||||
free (net->user);
|
||||
if (net->real)
|
||||
free (net->real);
|
||||
g_free (net->nick);
|
||||
g_free (net->nick2);
|
||||
g_free (net->user);
|
||||
g_free (net->real);
|
||||
free_and_clear (net->pass);
|
||||
if (net->favchanlist)
|
||||
g_slist_free_full (net->favchanlist, (GDestroyNotify) servlist_favchan_free);
|
||||
if (net->commandlist)
|
||||
g_slist_free_full (net->commandlist, (GDestroyNotify) servlist_command_free);
|
||||
if (net->comment)
|
||||
free (net->comment);
|
||||
if (net->encoding)
|
||||
free (net->encoding);
|
||||
free (net->name);
|
||||
free (net);
|
||||
g_free (net->encoding);
|
||||
g_free (net->name);
|
||||
g_free (net);
|
||||
|
||||
/* for safety */
|
||||
list = serv_list;
|
||||
@@ -1110,10 +1097,8 @@ servlist_net_add (char *name, char *comment, int prepend)
|
||||
{
|
||||
ircnet *net;
|
||||
|
||||
net = malloc (sizeof (ircnet));
|
||||
memset (net, 0, sizeof (ircnet));
|
||||
net->name = strdup (name);
|
||||
/* net->comment = strdup (comment);*/
|
||||
net = g_new0 (ircnet, 1);
|
||||
net->name = g_strdup (name);
|
||||
net->flags = FLAG_CYCLE | FLAG_USE_GLOBAL | FLAG_USE_PROXY;
|
||||
|
||||
if (prepend)
|
||||
@@ -1210,25 +1195,25 @@ servlist_load (void)
|
||||
switch (buf[0])
|
||||
{
|
||||
case 'I':
|
||||
net->nick = strdup (buf + 2);
|
||||
net->nick = g_strdup (buf + 2);
|
||||
break;
|
||||
case 'i':
|
||||
net->nick2 = strdup (buf + 2);
|
||||
net->nick2 = g_strdup (buf + 2);
|
||||
break;
|
||||
case 'U':
|
||||
net->user = strdup (buf + 2);
|
||||
net->user = g_strdup (buf + 2);
|
||||
break;
|
||||
case 'R':
|
||||
net->real = strdup (buf + 2);
|
||||
net->real = g_strdup (buf + 2);
|
||||
break;
|
||||
case 'P':
|
||||
net->pass = strdup (buf + 2);
|
||||
net->pass = g_strdup (buf + 2);
|
||||
break;
|
||||
case 'L':
|
||||
net->logintype = atoi (buf + 2);
|
||||
break;
|
||||
case 'E':
|
||||
net->encoding = strdup (buf + 2);
|
||||
net->encoding = g_strdup (buf + 2);
|
||||
break;
|
||||
case 'F':
|
||||
net->flags = atoi (buf + 2);
|
||||
@@ -1258,7 +1243,7 @@ servlist_load (void)
|
||||
case 'A':
|
||||
if (!net->pass)
|
||||
{
|
||||
net->pass = strdup (buf + 2);
|
||||
net->pass = g_strdup (buf + 2);
|
||||
if (!net->logintype)
|
||||
{
|
||||
net->logintype = LOGIN_SASL;
|
||||
@@ -1267,7 +1252,7 @@ servlist_load (void)
|
||||
case 'B':
|
||||
if (!net->pass)
|
||||
{
|
||||
net->pass = strdup (buf + 2);
|
||||
net->pass = g_strdup (buf + 2);
|
||||
if (!net->logintype)
|
||||
{
|
||||
net->logintype = LOGIN_NICKSERV;
|
||||
|
||||
@@ -45,7 +45,6 @@ typedef struct ircnet
|
||||
char *real;
|
||||
char *pass;
|
||||
int logintype;
|
||||
char *comment;
|
||||
char *encoding;
|
||||
GSList *servlist;
|
||||
GSList *commandlist;
|
||||
|
||||
@@ -504,9 +504,7 @@ _SSL_check_common_name (X509 *cert, const char *host)
|
||||
if (common_name_len < 0)
|
||||
return -1;
|
||||
|
||||
common_name = calloc (common_name_len + 1, 1);
|
||||
if (common_name == NULL)
|
||||
return -1;
|
||||
common_name = g_malloc0 (common_name_len + 1);
|
||||
|
||||
X509_NAME_get_text_by_NID (name, NID_commonName, common_name, common_name_len + 1);
|
||||
|
||||
@@ -535,7 +533,7 @@ _SSL_check_common_name (X509 *cert, const char *host)
|
||||
rv = 0;
|
||||
|
||||
out:
|
||||
free(common_name);
|
||||
g_free(common_name);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ scrollback_get_filename (session *sess)
|
||||
buf = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "scrollback" G_DIR_SEPARATOR_S "%s" G_DIR_SEPARATOR_S "%s.txt", get_xdir (), net, chan);
|
||||
else
|
||||
buf = NULL;
|
||||
free (chan);
|
||||
g_free (chan);
|
||||
|
||||
return buf;
|
||||
}
|
||||
@@ -406,7 +406,7 @@ log_create_filename (char *channame)
|
||||
char *tmp, *ret;
|
||||
int mbl;
|
||||
|
||||
ret = tmp = strdup (channame);
|
||||
ret = tmp = g_strdup (channame);
|
||||
while (*tmp)
|
||||
{
|
||||
mbl = g_utf8_skip[((unsigned char *)tmp)[0]];
|
||||
@@ -542,7 +542,7 @@ log_create_pathname (char *servname, char *channame, char *netname)
|
||||
|
||||
if (!netname)
|
||||
{
|
||||
netname = strdup ("NETWORK");
|
||||
netname = g_strdup ("NETWORK");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -552,7 +552,7 @@ log_create_pathname (char *servname, char *channame, char *netname)
|
||||
/* first, everything is in UTF-8 */
|
||||
if (!rfc_casecmp (channame, servname))
|
||||
{
|
||||
channame = strdup ("server");
|
||||
channame = g_strdup ("server");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -560,8 +560,8 @@ log_create_pathname (char *servname, char *channame, char *netname)
|
||||
}
|
||||
|
||||
log_insert_vars (fname, sizeof (fname), prefs.hex_irc_logmask, channame, netname, servname);
|
||||
free (channame);
|
||||
free (netname);
|
||||
g_free (channame);
|
||||
g_free (netname);
|
||||
|
||||
/* insert time/date */
|
||||
now = time (NULL);
|
||||
@@ -803,8 +803,6 @@ iso_8859_1_to_utf8 (unsigned char *text, int len, gsize *bytes_written)
|
||||
|
||||
/* worst case scenario: every byte turns into 3 bytes */
|
||||
res = output = g_malloc ((len * 3) + 1);
|
||||
if (!output)
|
||||
return NULL;
|
||||
|
||||
while (len)
|
||||
{
|
||||
@@ -1565,14 +1563,13 @@ pevent_load_defaults ()
|
||||
|
||||
for (i = 0; i < NUM_XP; i++)
|
||||
{
|
||||
if (pntevts_text[i])
|
||||
free (pntevts_text[i]);
|
||||
g_free (pntevts_text[i]);
|
||||
|
||||
/* make-te.c sets this 128 flag (DON'T call gettext() flag) */
|
||||
if (te[i].num_args & 128)
|
||||
pntevts_text[i] = strdup (te[i].def);
|
||||
pntevts_text[i] = g_strdup (te[i].def);
|
||||
else
|
||||
pntevts_text[i] = strdup (_(te[i].def));
|
||||
pntevts_text[i] = g_strdup (_(te[i].def));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1584,19 +1581,18 @@ pevent_make_pntevts ()
|
||||
|
||||
for (i = 0; i < NUM_XP; i++)
|
||||
{
|
||||
if (pntevts[i] != NULL)
|
||||
free (pntevts[i]);
|
||||
g_free (pntevts[i]);
|
||||
if (pevt_build_string (pntevts_text[i], &(pntevts[i]), &m) != 0)
|
||||
{
|
||||
snprintf (out, sizeof (out),
|
||||
_("Error parsing event %s.\nLoading default."), te[i].name);
|
||||
fe_message (out, FE_MSG_WARN);
|
||||
free (pntevts_text[i]);
|
||||
g_free (pntevts_text[i]);
|
||||
/* make-te.c sets this 128 flag (DON'T call gettext() flag) */
|
||||
if (te[i].num_args & 128)
|
||||
pntevts_text[i] = strdup (te[i].def);
|
||||
pntevts_text[i] = g_strdup (te[i].def);
|
||||
else
|
||||
pntevts_text[i] = strdup (_(te[i].def));
|
||||
pntevts_text[i] = g_strdup (_(te[i].def));
|
||||
if (pevt_build_string (pntevts_text[i], &(pntevts[i]), &m) != 0)
|
||||
{
|
||||
fprintf (stderr,
|
||||
@@ -1618,22 +1614,17 @@ pevent_make_pntevts ()
|
||||
static void
|
||||
pevent_trigger_load (int *i_penum, char **i_text, char **i_snd)
|
||||
{
|
||||
int penum = *i_penum, len;
|
||||
int penum = *i_penum;
|
||||
char *text = *i_text, *snd = *i_snd;
|
||||
|
||||
if (penum != -1 && text != NULL)
|
||||
{
|
||||
len = strlen (text) + 1;
|
||||
if (pntevts_text[penum])
|
||||
free (pntevts_text[penum]);
|
||||
pntevts_text[penum] = malloc (len);
|
||||
memcpy (pntevts_text[penum], text, len);
|
||||
g_free (pntevts_text[penum]);
|
||||
pntevts_text[penum] = g_strdup (text);
|
||||
}
|
||||
|
||||
if (text)
|
||||
free (text);
|
||||
if (snd)
|
||||
free (snd);
|
||||
g_free (text);
|
||||
g_free (snd);
|
||||
*i_text = NULL;
|
||||
*i_snd = NULL;
|
||||
*i_penum = 0;
|
||||
@@ -1686,7 +1677,7 @@ pevent_load (char *filename)
|
||||
close (fd);
|
||||
return 1;
|
||||
}
|
||||
ibuf = malloc (st.st_size);
|
||||
ibuf = g_malloc (st.st_size);
|
||||
read (fd, ibuf, st.st_size);
|
||||
close (fd);
|
||||
|
||||
@@ -1702,8 +1693,6 @@ pevent_load (char *filename)
|
||||
continue;
|
||||
*ofs = 0;
|
||||
ofs++;
|
||||
/*if (*ofs == 0)
|
||||
continue;*/
|
||||
|
||||
if (strcmp (buf, "event_name") == 0)
|
||||
{
|
||||
@@ -1713,53 +1702,16 @@ pevent_load (char *filename)
|
||||
continue;
|
||||
} else if (strcmp (buf, "event_text") == 0)
|
||||
{
|
||||
if (text)
|
||||
free (text);
|
||||
|
||||
#if 0
|
||||
/* This allows updating of old strings. We don't use new defaults
|
||||
if the user has customized the strings (.e.g a text theme).
|
||||
Hash of the old default is enough to identify and replace it.
|
||||
This only works in English. */
|
||||
|
||||
switch (g_str_hash (ofs))
|
||||
{
|
||||
case 0x526743a4:
|
||||
/* %C08,02 Hostmask PRIV NOTI CHAN CTCP INVI UNIG %O */
|
||||
text = strdup (te[XP_TE_IGNOREHEADER].def);
|
||||
break;
|
||||
|
||||
case 0xe91bc9c2:
|
||||
/* %C08,02 %O */
|
||||
text = strdup (te[XP_TE_IGNOREFOOTER].def);
|
||||
break;
|
||||
|
||||
case 0x1fbfdf22:
|
||||
/* -%C10-%C11-%O$tDCC RECV: Cannot open $1 for writing - aborting. */
|
||||
text = strdup (te[XP_TE_DCCFILEERR].def);
|
||||
break;
|
||||
|
||||
default:
|
||||
text = strdup (ofs);
|
||||
}
|
||||
#else
|
||||
text = strdup (ofs);
|
||||
#endif
|
||||
|
||||
g_free (text);
|
||||
text = g_strdup (ofs);
|
||||
continue;
|
||||
}/* else if (strcmp (buf, "event_sound") == 0)
|
||||
{
|
||||
if (snd)
|
||||
free (snd);
|
||||
snd = strdup (ofs);
|
||||
continue;
|
||||
}*/
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
pevent_trigger_load (&penum, &text, &snd);
|
||||
free (ibuf);
|
||||
g_free (ibuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1777,9 +1729,9 @@ pevent_check_all_loaded ()
|
||||
gtkutil_simpledialog(out); */
|
||||
/* make-te.c sets this 128 flag (DON'T call gettext() flag) */
|
||||
if (te[i].num_args & 128)
|
||||
pntevts_text[i] = strdup (te[i].def);
|
||||
pntevts_text[i] = g_strdup (te[i].def);
|
||||
else
|
||||
pntevts_text[i] = strdup (_(te[i].def));
|
||||
pntevts_text[i] = g_strdup (_(te[i].def));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1896,7 +1848,7 @@ pevt_build_string (const char *input, char **output, int *max_arg)
|
||||
int oi, ii, max = -1, len, x;
|
||||
|
||||
len = strlen (input);
|
||||
i = malloc (len + 1);
|
||||
i = g_malloc (len + 1);
|
||||
memcpy (i, input, len + 1);
|
||||
check_special_chars (i, TRUE);
|
||||
|
||||
@@ -1921,14 +1873,14 @@ pevt_build_string (const char *input, char **output, int *max_arg)
|
||||
}
|
||||
if (oi > 0)
|
||||
{
|
||||
s = (struct pevt_stage1 *) malloc (sizeof (struct pevt_stage1));
|
||||
s = g_new (struct pevt_stage1, 1);
|
||||
if (base == NULL)
|
||||
base = s;
|
||||
if (last != NULL)
|
||||
last->next = s;
|
||||
last = s;
|
||||
s->next = NULL;
|
||||
s->data = malloc (oi + sizeof (int) + 1);
|
||||
s->data = g_malloc (oi + sizeof (int) + 1);
|
||||
s->len = oi + sizeof (int) + 1;
|
||||
clen += oi + sizeof (int) + 1;
|
||||
s->data[0] = 0;
|
||||
@@ -1939,11 +1891,12 @@ pevt_build_string (const char *input, char **output, int *max_arg)
|
||||
if (ii == len)
|
||||
{
|
||||
fe_message ("String ends with a $", FE_MSG_WARN);
|
||||
return 1;
|
||||
goto err;
|
||||
}
|
||||
d = i[ii++];
|
||||
if (d == 'a')
|
||||
{ /* Hex value */
|
||||
{
|
||||
/* Hex value */
|
||||
x = 0;
|
||||
if (ii == len)
|
||||
goto a_len_error;
|
||||
@@ -1965,26 +1918,24 @@ pevt_build_string (const char *input, char **output, int *max_arg)
|
||||
o[oi++] = x;
|
||||
continue;
|
||||
|
||||
a_len_error:
|
||||
a_len_error:
|
||||
fe_message ("String ends in $a", FE_MSG_WARN);
|
||||
free (i);
|
||||
return 1;
|
||||
a_range_error:
|
||||
goto err;
|
||||
a_range_error:
|
||||
fe_message ("$a value is greater than 255", FE_MSG_WARN);
|
||||
free (i);
|
||||
return 1;
|
||||
goto err;
|
||||
}
|
||||
if (d == 't')
|
||||
{
|
||||
/* Tab - if tabnicks is set then write '\t' else ' ' */
|
||||
s = (struct pevt_stage1 *) malloc (sizeof (struct pevt_stage1));
|
||||
s = g_new (struct pevt_stage1, 1);
|
||||
if (base == NULL)
|
||||
base = s;
|
||||
if (last != NULL)
|
||||
last->next = s;
|
||||
last = s;
|
||||
s->next = NULL;
|
||||
s->data = malloc (1);
|
||||
s->data = g_malloc (1);
|
||||
s->len = 1;
|
||||
clen += 1;
|
||||
s->data[0] = 3;
|
||||
@@ -1995,20 +1946,19 @@ pevt_build_string (const char *input, char **output, int *max_arg)
|
||||
{
|
||||
snprintf (o, sizeof (o), "Error, invalid argument $%c\n", d);
|
||||
fe_message (o, FE_MSG_WARN);
|
||||
free (i);
|
||||
return 1;
|
||||
goto err;
|
||||
}
|
||||
d -= '0';
|
||||
if (max < d)
|
||||
max = d;
|
||||
s = (struct pevt_stage1 *) malloc (sizeof (struct pevt_stage1));
|
||||
s = g_new (struct pevt_stage1, 1);
|
||||
if (base == NULL)
|
||||
base = s;
|
||||
if (last != NULL)
|
||||
last->next = s;
|
||||
last = s;
|
||||
s->next = NULL;
|
||||
s->data = malloc (2);
|
||||
s->data = g_malloc (2);
|
||||
s->len = 2;
|
||||
clen += 2;
|
||||
s->data[0] = 1;
|
||||
@@ -2016,14 +1966,14 @@ pevt_build_string (const char *input, char **output, int *max_arg)
|
||||
}
|
||||
if (oi > 0)
|
||||
{
|
||||
s = (struct pevt_stage1 *) malloc (sizeof (struct pevt_stage1));
|
||||
s = g_new (struct pevt_stage1, 1);
|
||||
if (base == NULL)
|
||||
base = s;
|
||||
if (last != NULL)
|
||||
last->next = s;
|
||||
last = s;
|
||||
s->next = NULL;
|
||||
s->data = malloc (oi + sizeof (int) + 1);
|
||||
s->data = g_malloc (oi + sizeof (int) + 1);
|
||||
s->len = oi + sizeof (int) + 1;
|
||||
clen += oi + sizeof (int) + 1;
|
||||
s->data[0] = 0;
|
||||
@@ -2031,41 +1981,55 @@ pevt_build_string (const char *input, char **output, int *max_arg)
|
||||
memcpy (&(s->data[1 + sizeof (int)]), o, oi);
|
||||
oi = 0;
|
||||
}
|
||||
s = (struct pevt_stage1 *) malloc (sizeof (struct pevt_stage1));
|
||||
s = g_new (struct pevt_stage1, 1);
|
||||
if (base == NULL)
|
||||
base = s;
|
||||
if (last != NULL)
|
||||
last->next = s;
|
||||
last = s;
|
||||
s->next = NULL;
|
||||
s->data = malloc (1);
|
||||
s->data = g_malloc (1);
|
||||
s->len = 1;
|
||||
clen += 1;
|
||||
s->data[0] = 2;
|
||||
|
||||
oi = 0;
|
||||
s = base;
|
||||
obuf = malloc (clen);
|
||||
obuf = g_malloc (clen);
|
||||
|
||||
while (s)
|
||||
{
|
||||
next = s->next;
|
||||
memcpy (&obuf[oi], s->data, s->len);
|
||||
oi += s->len;
|
||||
free (s->data);
|
||||
free (s);
|
||||
g_free (s->data);
|
||||
g_free (s);
|
||||
s = next;
|
||||
}
|
||||
|
||||
free (i);
|
||||
g_free (i);
|
||||
|
||||
if (max_arg)
|
||||
*max_arg = max;
|
||||
if (output)
|
||||
*output = obuf;
|
||||
else
|
||||
free (obuf);
|
||||
g_free (obuf);
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
while (s)
|
||||
{
|
||||
next = s->next;
|
||||
g_free (s->data);
|
||||
g_free (s);
|
||||
s = next;
|
||||
}
|
||||
|
||||
g_free(i);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -2356,9 +2320,8 @@ sound_load_event (char *evt, char *file)
|
||||
|
||||
if (file[0] && pevent_find (evt, &i) != -1)
|
||||
{
|
||||
if (sound_files[i])
|
||||
free (sound_files[i]);
|
||||
sound_files[i] = strdup (file);
|
||||
g_free (sound_files[i]);
|
||||
sound_files[i] = g_strdup (file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ struct _tree
|
||||
tree *
|
||||
tree_new (tree_cmp_func *cmp, void *data)
|
||||
{
|
||||
tree *t = calloc (1, sizeof (tree));
|
||||
tree *t = g_new0 (tree, 1);
|
||||
t->cmp = cmp;
|
||||
t->data = data;
|
||||
return t;
|
||||
@@ -53,9 +53,8 @@ tree_destroy (tree *t)
|
||||
{
|
||||
if (t)
|
||||
{
|
||||
if (t->array)
|
||||
free (t->array);
|
||||
free (t);
|
||||
g_free (t->array);
|
||||
g_free (t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#ifndef HEXCHAT_TREE_H
|
||||
#define HEXCHAT_TREE_H
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
typedef struct _tree tree;
|
||||
|
||||
typedef int (tree_cmp_func) (const void *keya, const void *keyb, void *data);
|
||||
|
||||
@@ -53,7 +53,7 @@ static gboolean match_path (const char *word, int *start, int *end);
|
||||
static int
|
||||
url_free (char *url, void *data)
|
||||
{
|
||||
free (url);
|
||||
g_free (url);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -124,13 +124,7 @@ url_add (char *urltext, int len)
|
||||
return;
|
||||
}
|
||||
|
||||
data = malloc (len + 1);
|
||||
if (!data)
|
||||
{
|
||||
return;
|
||||
}
|
||||
memcpy (data, urltext, len);
|
||||
data[len] = 0;
|
||||
data = g_strndup (urltext, len);
|
||||
|
||||
if (data[len - 1] == '.') /* chop trailing dot */
|
||||
{
|
||||
@@ -151,7 +145,7 @@ url_add (char *urltext, int len)
|
||||
/* the URL is saved already, only continue if we need the URL grabber too */
|
||||
if (!prefs.hex_url_grabber)
|
||||
{
|
||||
free (data);
|
||||
g_free (data);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -163,7 +157,7 @@ url_add (char *urltext, int len)
|
||||
|
||||
if (url_find (data))
|
||||
{
|
||||
free (data);
|
||||
g_free (data);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -180,7 +174,7 @@ url_add (char *urltext, int len)
|
||||
|
||||
pos = tree_remove_at_pos (url_tree, 0);
|
||||
g_tree_remove (url_btree, pos);
|
||||
free (pos);
|
||||
g_free (pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,13 +121,12 @@ userlist_set_account (struct session *sess, char *nick, char *account)
|
||||
user = userlist_find (sess, nick);
|
||||
if (user)
|
||||
{
|
||||
if (user->account)
|
||||
free (user->account);
|
||||
g_free (user->account);
|
||||
|
||||
if (strcmp (account, "*") == 0)
|
||||
user->account = NULL;
|
||||
else
|
||||
user->account = strdup (account);
|
||||
user->account = g_strdup (account);
|
||||
|
||||
/* gui doesnt currently reflect login status, maybe later
|
||||
fe_userlist_rehash (sess, user); */
|
||||
@@ -148,14 +147,14 @@ userlist_add_hostname (struct session *sess, char *nick, char *hostname,
|
||||
{
|
||||
if (prefs.hex_gui_ulist_show_hosts)
|
||||
do_rehash = TRUE;
|
||||
user->hostname = strdup (hostname);
|
||||
user->hostname = g_strdup (hostname);
|
||||
}
|
||||
if (!user->realname && realname && *realname)
|
||||
user->realname = strdup (realname);
|
||||
user->realname = g_strdup (realname);
|
||||
if (!user->servername && servername)
|
||||
user->servername = strdup (servername);
|
||||
user->servername = g_strdup (servername);
|
||||
if (!user->account && account && strcmp (account, "0") != 0)
|
||||
user->account = strdup (account);
|
||||
user->account = g_strdup (account);
|
||||
if (away != 0xff)
|
||||
{
|
||||
if (user->away != away)
|
||||
@@ -175,15 +174,11 @@ userlist_add_hostname (struct session *sess, char *nick, char *hostname,
|
||||
static int
|
||||
free_user (struct User *user, gpointer data)
|
||||
{
|
||||
if (user->realname)
|
||||
free (user->realname);
|
||||
if (user->hostname)
|
||||
free (user->hostname);
|
||||
if (user->servername)
|
||||
free (user->servername);
|
||||
if (user->account)
|
||||
free (user->account);
|
||||
free (user);
|
||||
g_free (user->realname);
|
||||
g_free (user->hostname);
|
||||
g_free (user->servername);
|
||||
g_free (user->account);
|
||||
g_free (user);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -397,8 +392,7 @@ userlist_add (struct session *sess, char *name, char *hostname,
|
||||
|
||||
notify_set_online (sess->server, name + prefix_chars, tags_data);
|
||||
|
||||
user = malloc (sizeof (struct User));
|
||||
memset (user, 0, sizeof (struct User));
|
||||
user = g_new0 (struct User, 1);
|
||||
|
||||
user->access = acc;
|
||||
|
||||
@@ -408,7 +402,7 @@ userlist_add (struct session *sess, char *name, char *hostname,
|
||||
|
||||
/* add it to our linked list */
|
||||
if (hostname)
|
||||
user->hostname = strdup (hostname);
|
||||
user->hostname = g_strdup (hostname);
|
||||
safe_strcpy (user->nick, name + prefix_chars, NICKLEN);
|
||||
/* is it me? */
|
||||
if (!sess->server->p_cmp (user->nick, sess->server->nick))
|
||||
@@ -417,9 +411,9 @@ userlist_add (struct session *sess, char *name, char *hostname,
|
||||
if (sess->server->have_extjoin)
|
||||
{
|
||||
if (account && *account)
|
||||
user->account = strdup (account);
|
||||
user->account = g_strdup (account);
|
||||
if (realname && *realname)
|
||||
user->realname = strdup (realname);
|
||||
user->realname = g_strdup (realname);
|
||||
}
|
||||
|
||||
row = userlist_insertname (sess, user);
|
||||
@@ -427,13 +421,10 @@ userlist_add (struct session *sess, char *name, char *hostname,
|
||||
/* duplicate? some broken servers trigger this */
|
||||
if (row == -1)
|
||||
{
|
||||
if (user->hostname)
|
||||
free (user->hostname);
|
||||
if (user->account)
|
||||
free (user->account);
|
||||
if (user->realname)
|
||||
free (user->realname);
|
||||
free (user);
|
||||
g_free (user->hostname);
|
||||
g_free (user->account);
|
||||
g_free (user->realname);
|
||||
g_free (user);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -619,8 +619,6 @@ get_sys_str (int with_cpu)
|
||||
if (buf)
|
||||
return buf;
|
||||
|
||||
buf = malloc (128);
|
||||
|
||||
uname (&un);
|
||||
|
||||
#if defined (USING_LINUX) || defined (USING_FREEBSD) || defined (__APPLE__) || defined (__CYGWIN__)
|
||||
@@ -629,14 +627,16 @@ get_sys_str (int with_cpu)
|
||||
{
|
||||
double cpuspeed = ( mhz > 1000 ) ? mhz / 1000 : mhz;
|
||||
const char *cpuspeedstr = ( mhz > 1000 ) ? "GHz" : "MHz";
|
||||
snprintf (buf, 128,
|
||||
(cpus == 1) ? "%s %s [%s/%.2f%s]" : "%s %s [%s/%.2f%s/SMP]",
|
||||
un.sysname, un.release, un.machine,
|
||||
cpuspeed, cpuspeedstr);
|
||||
buf = g_strdup_printf (
|
||||
(cpus == 1) ? "%s %s [%s/%.2f%s]" : "%s %s [%s/%.2f%s/SMP]",
|
||||
un.sysname, un.release, un.machine,
|
||||
cpuspeed, cpuspeedstr);
|
||||
}
|
||||
else
|
||||
buf = g_strdup_printf ("%s %s", un.sysname, un.release);
|
||||
#else
|
||||
buf = g_strdup_printf ("%s %s", un.sysname, un.release);
|
||||
#endif
|
||||
snprintf (buf, 128, "%s %s", un.sysname, un.release);
|
||||
|
||||
return buf;
|
||||
}
|
||||
@@ -1503,7 +1503,7 @@ parse_dh (char *str, DH **dh_out, unsigned char **secret_out, int *keysize_out)
|
||||
{
|
||||
DH *dh;
|
||||
guchar *data, *decoded_data;
|
||||
guchar *secret;
|
||||
guchar *secret = NULL;
|
||||
gsize data_len;
|
||||
guint size;
|
||||
guint16 size16;
|
||||
@@ -1555,7 +1555,7 @@ parse_dh (char *str, DH **dh_out, unsigned char **secret_out, int *keysize_out)
|
||||
if (!(DH_generate_key (dh)))
|
||||
goto fail;
|
||||
|
||||
secret = (unsigned char*)malloc (DH_size(dh));
|
||||
secret = g_malloc (DH_size (dh));
|
||||
key_size = DH_compute_key (secret, pubkey, dh);
|
||||
if (key_size == -1)
|
||||
goto fail;
|
||||
@@ -1568,7 +1568,9 @@ parse_dh (char *str, DH **dh_out, unsigned char **secret_out, int *keysize_out)
|
||||
return 1;
|
||||
|
||||
fail:
|
||||
g_free (secret);
|
||||
g_free (decoded_data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1576,7 +1578,7 @@ char *
|
||||
encode_sasl_pass_blowfish (char *user, char *pass, char *data)
|
||||
{
|
||||
DH *dh;
|
||||
char *response, *ret;
|
||||
char *response, *ret = NULL;
|
||||
unsigned char *secret;
|
||||
unsigned char *encrypted_pass;
|
||||
char *plain_pass;
|
||||
@@ -1591,10 +1593,8 @@ encode_sasl_pass_blowfish (char *user, char *pass, char *data)
|
||||
return NULL;
|
||||
BF_set_key (&key, key_size, secret);
|
||||
|
||||
encrypted_pass = (guchar*)malloc (pass_len);
|
||||
memset (encrypted_pass, 0, pass_len);
|
||||
plain_pass = (char*)malloc (pass_len);
|
||||
memset (plain_pass, 0, pass_len);
|
||||
encrypted_pass = g_malloc0 (pass_len);
|
||||
plain_pass = g_malloc0 (pass_len);
|
||||
memcpy (plain_pass, pass, strlen(pass));
|
||||
out_ptr = (char*)encrypted_pass;
|
||||
in_ptr = (char*)plain_pass;
|
||||
@@ -1604,7 +1604,7 @@ encode_sasl_pass_blowfish (char *user, char *pass, char *data)
|
||||
|
||||
/* Create response */
|
||||
length = 2 + BN_num_bytes (dh->pub_key) + pass_len + user_len + 1;
|
||||
response = (char*)malloc (length);
|
||||
response = g_malloc0 (length);
|
||||
out_ptr = response;
|
||||
|
||||
/* our key */
|
||||
@@ -1623,11 +1623,12 @@ encode_sasl_pass_blowfish (char *user, char *pass, char *data)
|
||||
|
||||
ret = g_base64_encode ((const guchar*)response, length);
|
||||
|
||||
DH_free (dh);
|
||||
free (plain_pass);
|
||||
free (encrypted_pass);
|
||||
free (secret);
|
||||
free (response);
|
||||
g_free (response);
|
||||
|
||||
DH_free(dh);
|
||||
g_free (plain_pass);
|
||||
g_free (encrypted_pass);
|
||||
g_free (secret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1653,10 +1654,8 @@ encode_sasl_pass_aes (char *user, char *pass, char *data)
|
||||
if (!parse_dh (data, &dh, &secret, &key_size))
|
||||
return NULL;
|
||||
|
||||
encrypted_userpass = (guchar*)malloc (userpass_len);
|
||||
memset (encrypted_userpass, 0, userpass_len);
|
||||
plain_userpass = (guchar*)malloc (userpass_len);
|
||||
memset (plain_userpass, 0, userpass_len);
|
||||
encrypted_userpass = g_malloc0 (userpass_len);
|
||||
plain_userpass = g_malloc0 (userpass_len);
|
||||
|
||||
/* create message */
|
||||
/* format of: <username>\0<password>\0<padding> */
|
||||
@@ -1687,7 +1686,7 @@ encode_sasl_pass_aes (char *user, char *pass, char *data)
|
||||
/* Create response */
|
||||
/* format of: <size pubkey><pubkey><iv (always 16 bytes)><ciphertext> */
|
||||
length = 2 + key_size + sizeof(iv) + userpass_len;
|
||||
response = (char*)malloc (length);
|
||||
response = g_malloc (length);
|
||||
out_ptr = response;
|
||||
|
||||
/* our key */
|
||||
@@ -1708,11 +1707,10 @@ encode_sasl_pass_aes (char *user, char *pass, char *data)
|
||||
|
||||
end:
|
||||
DH_free (dh);
|
||||
free (plain_userpass);
|
||||
free (encrypted_userpass);
|
||||
free (secret);
|
||||
if (response)
|
||||
free (response);
|
||||
g_free (plain_userpass);
|
||||
g_free (encrypted_userpass);
|
||||
g_free (secret);
|
||||
g_free (response);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user