diff options
author | kyak <bas@bmail.ru> | 2015-08-26 09:34:48 +0300 |
---|---|---|
committer | kyak <bas@bmail.ru> | 2015-08-26 09:34:48 +0300 |
commit | 0435331912f5d975c4cbef9b018bb89c07e610eb (patch) | |
tree | b41f723bacf45aa045253c06ca3392c44a4c2140 /src | |
parent | 8e71d6ec739ec74fbb5c712e9341d4319a17d8f5 (diff) | |
download | irssi-0435331912f5d975c4cbef9b018bb89c07e610eb.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/irc/core/irc-expandos.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/irc/core/irc-expandos.c b/src/irc/core/irc-expandos.c index cc46ece5..f26c9699 100644 --- a/src/irc/core/irc-expandos.c +++ b/src/irc/core/irc-expandos.c @@ -82,13 +82,16 @@ static char *expando_hostname(SERVER_REC *server, void *item, int *free_ret) IRC_SERVER_REC *ircserver; char hostname[100]; char **list; + char *hostname_split; ircserver = IRC_SERVER(server); /* prefer the _real_ /userhost reply */ if (ircserver != NULL && ircserver->userhost != NULL) { 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 */ @@ -96,7 +99,7 @@ static char *expando_hostname(SERVER_REC *server, void *item, int *free_ret) if (gethostname(hostname, sizeof(hostname)) != 0 || *hostname == '\0') strcpy(hostname, "??"); - return g_strconcat(hostname, NULL); + return g_strdup(hostname); } /* user mode in active server */ |