summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-02-03 15:43:03 +0100
committerThomas Haller <thaller@redhat.com>2023-02-08 09:51:25 +0100
commit5dc07174d31e4b4beac388f77ad30684dc4014f8 (patch)
treec19ce93948cee0f5e0401ea58b8834c892e696cd
parent89734c75539b7a0b1e5918eb9a785f144dd3abe9 (diff)
downloadNetworkManager-5dc07174d31e4b4beac388f77ad30684dc4014f8.tar.gz
cli: use "free()" for string from readline
Since glib 2.45, we are guaranteed that g_free() just calls free(), so both can be used interchangeably. However, we still only depend on glib 2.40. In any case, it's ugly to mix the two. Memory allocated by plain malloc(), should be only freed with free(). The buffer in question comes from readline, which allocates it using the system allocator. Fixes: 995229181cac ('cli: remove editor thread')
-rw-r--r--src/nmcli/common.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/nmcli/common.c b/src/nmcli/common.c
index 008a3cec28..4229f66034 100644
--- a/src/nmcli/common.c
+++ b/src/nmcli/common.c
@@ -947,7 +947,6 @@ read_again:
if (nmc_config->in_editor || (rl_string && *rl_string)) {
/* In editor, or the line is not empty */
/* Call readline again to get new prompt (repeat) */
- g_free(rl_string);
goto read_again;
} else {
/* Not in editor and line is empty, exit */
@@ -960,10 +959,8 @@ read_again:
}
/* Return NULL, not empty string */
- if (rl_string && *rl_string == '\0') {
- g_free(rl_string);
- rl_string = NULL;
- }
+ if (rl_string && *rl_string == '\0')
+ nm_clear_free(&rl_string);
nm_clear_g_source_inst(&io_source);