diff options
author | Thomas Haller <thaller@redhat.com> | 2023-02-03 15:53:31 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2023-02-09 14:10:18 +0100 |
commit | 4ac1d3d0fb7a17d78259164f88dd33551f223bfb (patch) | |
tree | e78684521b4dc8d6f1bee7f9597907520679b373 | |
parent | 5199bd51e2a1551586df033107fd10686d0f48cf (diff) | |
download | NetworkManager-4ac1d3d0fb7a17d78259164f88dd33551f223bfb.tar.gz |
cli: fix leaking "value" string in ask_option()
Fixes: c5324ed285af ('nmcli: streamline connection addition')
(cherry picked from commit ea3e61047f8e5010d3aac8d074f2b2a55952d2d1)
(cherry picked from commit e60ff37f79dea291c43a2cc8b6132392e6c96c7c)
-rw-r--r-- | src/nmcli/connections.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/nmcli/connections.c b/src/nmcli/connections.c index 8c6ebd9897..7e2ef690e8 100644 --- a/src/nmcli/connections.c +++ b/src/nmcli/connections.c @@ -5595,8 +5595,8 @@ next: static void ask_option(NmCli *nmc, NMConnection *connection, const NMMetaAbstractInfo *abstract_info) { - char *value; - GError *error = NULL; + gs_free char *value = NULL; + gs_free_error GError *error = NULL; gs_free char *prompt = NULL; gboolean multi; const char *setting_name, *property_name; @@ -5632,11 +5632,13 @@ ask_option(NmCli *nmc, NMConnection *connection, const NMMetaAbstractInfo *abstr g_print(_("You can specify this option more than once. Press <Enter> when you're done.\n")); again: + nm_clear_g_free(&value); + g_clear_error(&error); + value = nmc_readline(&nmc->nmc_config, "%s", prompt); if (!set_option(nmc, connection, abstract_info, value, FALSE, &error)) { g_printerr("%s\n", error->message); - g_clear_error(&error); goto again; } |