patch file_completion crash
Build project / build (push) Successful in 1m0s

This commit is contained in:
Arthur Barraux
2026-01-13 15:20:18 +01:00
parent de4fa78221
commit d0afd4f304
+1 -3
View File
@@ -50,7 +50,7 @@ const char *file_completion(const char *path) {
if (last_slash) { if (last_slash) {
dir_len = last_slash - path + 1; // length of dir_path dir_len = last_slash - path + 1; // length of dir_path
strncpy(directory, path, dir_len); 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); strncpy(predict, last_slash + 1, predict_len);
directory[dir_len] = '\0'; directory[dir_len] = '\0';
predict[predict_len] = '\0'; predict[predict_len] = '\0';
@@ -73,8 +73,6 @@ const char *file_completion(const char *path) {
strcat(full_path, "/"); // add slash for directories strcat(full_path, "/"); // add slash for directories
} }
closedir(dir); closedir(dir);
dir = NULL;
free(entry);
return strdup(full_path); return strdup(full_path);
} }