Commit 133ed4e2 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

tabbing: don't null-terminate a directory name on the slash but after it

This fixes https://savannah.gnu.org/bugs/?47786.
No related merge requests found
Showing with 3 additions and 2 deletions
+3 -2
...@@ -2675,12 +2675,13 @@ char **cwd_tab_completion(const char *buf, bool allow_files, size_t ...@@ -2675,12 +2675,13 @@ char **cwd_tab_completion(const char *buf, bool allow_files, size_t
*num_matches = 0; *num_matches = 0;
null_at(&dirname, buf_len); null_at(&dirname, buf_len);
/* If there's a / in the name, strip out the directory part. */ /* If there's a / in the name, split out filename and directory parts. */
slash = strrchr(dirname, '/'); slash = strrchr(dirname, '/');
if (slash != NULL) { if (slash != NULL) {
char *wasdirname = dirname; char *wasdirname = dirname;
filename = mallocstrcpy(NULL, slash + 1); filename = mallocstrcpy(NULL, ++slash);
/* Cut off the filename part after the slash. */
*slash = '\0'; *slash = '\0';
dirname = real_dir_from_tilde(dirname); dirname = real_dir_from_tilde(dirname);
free(wasdirname); free(wasdirname);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment