fix(fileio.c): don't use uninitialized memory (#22031)

This commit is contained in:
zeertzjq 2023-01-28 13:06:45 +08:00 committed by GitHub
parent 881d4adb59
commit b4c4c232ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5439,6 +5439,10 @@ bool match_file_list(char *list, char *sfname, char *ffname)
char *file_pat_to_reg_pat(const char *pat, const char *pat_end, char *allow_dirs, int no_bslash)
FUNC_ATTR_NONNULL_ARG(1)
{
if (allow_dirs != NULL) {
*allow_dirs = false;
}
if (pat_end == NULL) {
pat_end = pat + strlen(pat);
}
@ -5447,10 +5451,6 @@ char *file_pat_to_reg_pat(const char *pat, const char *pat_end, char *allow_dirs
return xstrdup("^$");
}
if (allow_dirs != NULL) {
*allow_dirs = false;
}
size_t size = 2; // '^' at start, '$' at end.
for (const char *p = pat; p < pat_end; p++) {