fix: fix off-by-one in tabcompletion module

This commit is contained in:
2026-06-18 12:21:19 +02:00
parent a96519f8a6
commit e3c551b9f6
+3 -3
View File
@@ -134,7 +134,7 @@ int get_completions( // returns no. of results
int inc = find_first_slash_pos(names[i]) + 1;
if (montauk::starts_with(names[i] + inc, (const char*)string)) {
if (r > arrayMax)
if (r >= arrayMax)
break;
if (!is_executable(names[i]))
@@ -154,7 +154,7 @@ int get_completions( // returns no. of results
for (size_t i = 0; i < builtins_count; i++) {
if (montauk::starts_with(shell_builtins[i], (const char*)string)) {
if (r > arrayMax)
if (r >= arrayMax)
break;
array[r] = (char *)shell_builtins[i];
@@ -180,7 +180,7 @@ int get_completions( // returns no. of results
}
if (montauk::starts_with(cwd_entry_path, (const char*)string)) {
if (r > arrayMax)
if (r >= arrayMax)
break;
array[r] = (char *)cwd_entry_path;