aboutsummaryrefslogtreecommitdiff
path: root/util/readline.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/readline.c')
-rw-r--r--util/readline.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/util/readline.c b/util/readline.c
index 8441be484c..a3fd2cb466 100644
--- a/util/readline.c
+++ b/util/readline.c
@@ -279,9 +279,7 @@ static void readline_completion(ReadLineState *rs)
rs->nb_completions = 0;
- cmdline = g_malloc(rs->cmd_buf_index + 1);
- memcpy(cmdline, rs->cmd_buf, rs->cmd_buf_index);
- cmdline[rs->cmd_buf_index] = '\0';
+ cmdline = g_strndup(rs->cmd_buf, rs->cmd_buf_index);
rs->completion_finder(rs->opaque, cmdline);
g_free(cmdline);