mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 14:38:32 +00:00
No OOM error condition in save_patterns()
This commit is contained in:

committed by
Thiago de Arruda

parent
c4c855a129
commit
aa32fbb838
@@ -90,8 +90,8 @@ static int did_set_icon = FALSE;
|
|||||||
static int have_wildcard(int, char_u **);
|
static int have_wildcard(int, char_u **);
|
||||||
static int have_dollars(int, char_u **);
|
static int have_dollars(int, char_u **);
|
||||||
|
|
||||||
static int save_patterns(int num_pat, char_u **pat, int *num_file,
|
static void save_patterns(int num_pat, char_u **pat, int *num_file,
|
||||||
char_u ***file);
|
char_u ***file);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write s[len] to the screen.
|
* Write s[len] to the screen.
|
||||||
@@ -1067,8 +1067,10 @@ int flags; /* EW_* flags */
|
|||||||
* If there are no wildcards, just copy the names to allocated memory.
|
* If there are no wildcards, just copy the names to allocated memory.
|
||||||
* Saves a lot of time, because we don't have to start a new shell.
|
* Saves a lot of time, because we don't have to start a new shell.
|
||||||
*/
|
*/
|
||||||
if (!have_wildcard(num_pat, pat))
|
if (!have_wildcard(num_pat, pat)) {
|
||||||
return save_patterns(num_pat, pat, num_file, file);
|
save_patterns(num_pat, pat, num_file, file);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
# ifdef HAVE_SANDBOX
|
# ifdef HAVE_SANDBOX
|
||||||
/* Don't allow any shell command in the sandbox. */
|
/* Don't allow any shell command in the sandbox. */
|
||||||
@@ -1433,14 +1435,16 @@ int flags; /* EW_* flags */
|
|||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
notfound:
|
notfound:
|
||||||
if (flags & EW_NOTFOUND)
|
if (flags & EW_NOTFOUND) {
|
||||||
return save_patterns(num_pat, pat, num_file, file);
|
save_patterns(num_pat, pat, num_file, file);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int save_patterns(num_pat, pat, num_file, file)
|
static void save_patterns(num_pat, pat, num_file, file)
|
||||||
int num_pat;
|
int num_pat;
|
||||||
char_u **pat;
|
char_u **pat;
|
||||||
int *num_file;
|
int *num_file;
|
||||||
@@ -1449,9 +1453,8 @@ char_u ***file;
|
|||||||
int i;
|
int i;
|
||||||
char_u *s;
|
char_u *s;
|
||||||
|
|
||||||
*file = (char_u **)alloc(num_pat * sizeof(char_u *));
|
*file = xmalloc((size_t)num_pat * sizeof(char_u *));
|
||||||
if (*file == NULL)
|
|
||||||
return FAIL;
|
|
||||||
for (i = 0; i < num_pat; i++) {
|
for (i = 0; i < num_pat; i++) {
|
||||||
s = vim_strsave(pat[i]);
|
s = vim_strsave(pat[i]);
|
||||||
if (s != NULL)
|
if (s != NULL)
|
||||||
@@ -1461,7 +1464,6 @@ char_u ***file;
|
|||||||
(*file)[i] = s;
|
(*file)[i] = s;
|
||||||
}
|
}
|
||||||
*num_file = num_pat;
|
*num_file = num_pat;
|
||||||
return OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user