1
0
mirror of https://github.com/irssi/irssi.git synced 2025-02-02 15:08:01 -05:00

Clean up in hostname expando before return

Clean up the vector resulting from g_strsplit before
returning from expando_hostname(). Also, use g_strdup()
instead of g_strconcat() to return the pointer to hostname.
This commit is contained in:
kyak 2015-08-26 09:34:48 +03:00
parent 8e71d6ec73
commit 0435331912

View File

@ -82,13 +82,16 @@ static char *expando_hostname(SERVER_REC *server, void *item, int *free_ret)
IRC_SERVER_REC *ircserver; IRC_SERVER_REC *ircserver;
char hostname[100]; char hostname[100];
char **list; char **list;
char *hostname_split;
ircserver = IRC_SERVER(server); ircserver = IRC_SERVER(server);
/* prefer the _real_ /userhost reply */ /* prefer the _real_ /userhost reply */
if (ircserver != NULL && ircserver->userhost != NULL) { if (ircserver != NULL && ircserver->userhost != NULL) {
list = g_strsplit(ircserver->userhost, "@", -1); list = g_strsplit(ircserver->userhost, "@", -1);
return list[1]; hostname_split = g_strdup(list[1]);
g_strfreev(list);
return hostname_split;
} }
/* haven't received userhost reply yet. guess something */ /* haven't received userhost reply yet. guess something */
@ -96,7 +99,7 @@ static char *expando_hostname(SERVER_REC *server, void *item, int *free_ret)
if (gethostname(hostname, sizeof(hostname)) != 0 || *hostname == '\0') if (gethostname(hostname, sizeof(hostname)) != 0 || *hostname == '\0')
strcpy(hostname, "??"); strcpy(hostname, "??");
return g_strconcat(hostname, NULL); return g_strdup(hostname);
} }
/* user mode in active server */ /* user mode in active server */