about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
Diffstat (limited to 'src/command')
-rw-r--r--src/command/command.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/command/command.c b/src/command/command.c
index b09c91fb..49f84ad0 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -1169,7 +1169,6 @@ cmd_autocomplete(char *input, int *size)
 {
     int i = 0;
     char *found = NULL;
-    char *auto_msg = NULL;
     char inp_cpy[*size];
 
     // autocomplete command
@@ -1180,8 +1179,7 @@ cmd_autocomplete(char *input, int *size)
         inp_cpy[i] = '\0';
         found = autocomplete_complete(commands_ac, inp_cpy);
         if (found != NULL) {
-            auto_msg = (char *) malloc(strlen(found) + 1);
-            strcpy(auto_msg, found);
+            char *auto_msg = strdup(found);
             inp_replace_input(input, auto_msg, size);
             free(auto_msg);
             free(found);