0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 9.0.0231: expanding "**" may loop forever with directory links

Problem:    Expanding "**" may loop forever with directory links.
Solution:   Check for being interrupted. (closes #10946)
This commit is contained in:
Bram Moolenaar
2022-08-20 19:26:14 +01:00
parent 2984ed31d9
commit 57e95179ab
3 changed files with 12 additions and 6 deletions

View File

@@ -3180,8 +3180,9 @@ expand_wildcards(
/*
* Move the names where 'suffixes' match to the end.
* Skip when interrupted, the result probably won't be used.
*/
if (*num_files > 1)
if (*num_files > 1 && !got_int)
{
non_suf_match = 0;
for (i = 0; i < *num_files; ++i)
@@ -3719,7 +3720,7 @@ unix_expandpath(
// Find all matching entries
if (dirp != NULL)
{
for (;;)
while (!got_int)
{
dp = readdir(dirp);
if (dp == NULL)
@@ -3789,8 +3790,10 @@ unix_expandpath(
vim_free(buf);
vim_regfree(regmatch.regprog);
// When interrupted the matches probably won't be used and sorting can be
// slow, thus skip it.
matches = gap->ga_len - start_len;
if (matches > 0)
if (matches > 0 && !got_int)
qsort(((char_u **)gap->ga_data) + start_len, matches,
sizeof(char_u *), pstrcmp);
return matches;
@@ -3918,7 +3921,7 @@ gen_expand_wildcards(
*/
ga_init2(&ga, sizeof(char_u *), 30);
for (i = 0; i < num_pat; ++i)
for (i = 0; i < num_pat && !got_int; ++i)
{
add_pat = -1;
p = pat[i];