fix(path): crash with nvim_get_runtime_file during wildcard expansion (#32992)

Problem:  Crash with nvim_get_runtime_file during wildcard expansion.
Solution: Ensure recursive gen_expand_wildcards() is allowed when
          calling os_breakcheck()
This commit is contained in:
zeertzjq
2025-03-19 22:36:08 +08:00
committed by GitHub
parent 21cbd90007
commit 42db8b1759

View File

@ -1325,7 +1325,11 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i
recursive = true; recursive = true;
did_expand_in_path = true; did_expand_in_path = true;
} else { } else {
// Recursive gen_expand_wildcards() can only happen here when called from an
// event handler in os_breakcheck(), in which case it should be allowed.
recursive = false;
size_t tmp_add_pat = path_expand(&ga, p, flags); size_t tmp_add_pat = path_expand(&ga, p, flags);
recursive = true;
assert(tmp_add_pat <= INT_MAX); assert(tmp_add_pat <= INT_MAX);
add_pat = (int)tmp_add_pat; add_pat = (int)tmp_add_pat;
} }
@ -1349,7 +1353,11 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i
} }
if (did_expand_in_path && !GA_EMPTY(&ga) && (flags & (EW_PATH | EW_CDPATH))) { if (did_expand_in_path && !GA_EMPTY(&ga) && (flags & (EW_PATH | EW_CDPATH))) {
// Recursive gen_expand_wildcards() can only happen here when called from an
// event handler in os_breakcheck(), in which case it should be allowed.
recursive = false;
uniquefy_paths(&ga, p, path_option); uniquefy_paths(&ga, p, path_option);
recursive = true;
} }
if (p != pat[i]) { if (p != pat[i]) {
xfree(p); xfree(p);