diff --git a/src/input.c b/src/input.c index e092b8e..8843394 100644 --- a/src/input.c +++ b/src/input.c @@ -50,7 +50,7 @@ const char *file_completion(const char *path) { if (last_slash) { dir_len = last_slash - path + 1; // length of dir_path strncpy(directory, path, dir_len); - predict_len = strlen(path) - dir_len - 1; + predict_len = strlen(path) - dir_len; strncpy(predict, last_slash + 1, predict_len); directory[dir_len] = '\0'; predict[predict_len] = '\0'; @@ -73,9 +73,7 @@ const char *file_completion(const char *path) { strcat(full_path, "/"); // add slash for directories } closedir(dir); - dir = NULL; - free(entry); - + return strdup(full_path); } }