From 0435331912f5d975c4cbef9b018bb89c07e610eb Mon Sep 17 00:00:00 2001 From: kyak Date: Wed, 26 Aug 2015 09:34:48 +0300 Subject: 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. --- src/irc/core/irc-expandos.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/irc') 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 */ -- cgit v1.2.3