From e886ba0c6fed433b561c4d0efb4f91b0681aa788 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Fri, 30 Dec 2022 19:36:53 +0100 Subject: fix more memory leaks Signed-off-by: Steffen Jaeckel --- src/command/cmd_ac.c | 4 ++-- src/command/cmd_funcs.c | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src/command') diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 559b3bda..e48e0ae2 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -2849,7 +2849,7 @@ _omemo_autocomplete(ProfWin* window, const char* const input, gboolean previous) gboolean result; gchar** args = parse_args(input, 2, 3, &result); if (result) { - gchar* jid = g_strdup(args[1]); + auto_gchar gchar* jid = g_strdup(args[1]); found = autocomplete_param_no_with_func(input, "/omemo trust", 4, omemo_fingerprint_autocomplete, previous, jid); if (found) { return found; @@ -2876,7 +2876,7 @@ _omemo_autocomplete(ProfWin* window, const char* const input, gboolean previous) gboolean result; gchar** args = parse_args(input, 2, 3, &result); if (result) { - gchar* jid = g_strdup(args[1]); + auto_gchar gchar* jid = g_strdup(args[1]); found = autocomplete_param_no_with_func(input, "/omemo untrust", 4, omemo_fingerprint_autocomplete, previous, jid); if (found) { return found; diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index bbfb3cb8..56a18bdb 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -8436,18 +8436,19 @@ _cmd_execute(ProfWin* window, const char* const command, const char* const inp) int i = 0; while (cmd->sub_funcs[i].cmd) { if (g_strcmp0(args[0], (char*)cmd->sub_funcs[i].cmd) == 0) { - gboolean result = cmd->sub_funcs[i].func(window, command, args); - g_strfreev(args); - return result; + result = cmd->sub_funcs[i].func(window, command, args); + goto out; } i++; } } if (!cmd->func) { ui_invalid_command_usage(cmd->cmd, cmd->setting_func); - return TRUE; + result = TRUE; + goto out; } - gboolean result = cmd->func(window, command, args); + result = cmd->func(window, command, args); +out: g_strfreev(args); return result; } else if (plugins_run_command(inp)) { @@ -8887,6 +8888,7 @@ cmd_omemo_fingerprint(ProfWin* window, const char* const command, gchar** args) free(formatted_fingerprint); } + jid_destroy(jid); g_list_free(fingerprints); win_println(window, THEME_DEFAULT, "-", "You can trust it with '/omemo trust '"); -- cgit 1.4.1-2-gfad0 ass='oid'>052140f ^