From 6d11cd2db3bd22b9ddac0b4a59c610939100694e Mon Sep 17 00:00:00 2001 From: Dmitry Podgorny Date: Mon, 14 Oct 2019 00:19:08 +0300 Subject: Fix memory leak in cmd_join() room is either argv[0] or allocated by GString. We have to free memory in the 2nd case. Replace argv[0] with g_strdup(argv[0]) in order to make unconditional g_free(). --- src/command/cmd_funcs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/command') diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 2c68cd1f..9b2622e7 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -3606,7 +3606,7 @@ cmd_join(ProfWin *window, const char *const command, gchar **args) // full room jid supplied (room@server) if (room_arg->localpart) { - room = args[0]; + room = g_strdup(args[0]); // server not supplied (room), use account preference } else if (account->muc_service) { @@ -3631,6 +3631,7 @@ cmd_join(ProfWin *window, const char *const command, gchar **args) if (!parsed) { cons_bad_cmd_usage(command); cons_show(""); + g_free(room); jid_destroy(room_arg); return TRUE; } @@ -3657,6 +3658,7 @@ cmd_join(ProfWin *window, const char *const command, gchar **args) ui_switch_to_room(room); } + g_free(room); jid_destroy(room_arg); account_free(account); -- cgit 1.4.1-2-gfad0