aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authorFelipe Oliveira Carvalho <felipekde@gmail.com>2014-04-19 03:27:07 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-04-24 10:31:31 -0300
commitaa32fbb83807d14f0fbf864291ecc8688c619213 (patch)
tree8ed342c37e20df333ab247ab8401a883639a3d3c /src/os_unix.c
parentc4c855a129e9bbc6f36c77d929830b4feefffeb0 (diff)
downloadrneovim-aa32fbb83807d14f0fbf864291ecc8688c619213.tar.gz
rneovim-aa32fbb83807d14f0fbf864291ecc8688c619213.tar.bz2
rneovim-aa32fbb83807d14f0fbf864291ecc8688c619213.zip
No OOM error condition in save_patterns()
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 03ea2a7c0d..b361b5031a 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -90,8 +90,8 @@ static int did_set_icon = FALSE;
static int have_wildcard(int, char_u **);
static int have_dollars(int, char_u **);
-static int save_patterns(int num_pat, char_u **pat, int *num_file,
- char_u ***file);
+static void save_patterns(int num_pat, char_u **pat, int *num_file,
+ char_u ***file);
/*
* 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.
* Saves a lot of time, because we don't have to start a new shell.
*/
- if (!have_wildcard(num_pat, pat))
- return save_patterns(num_pat, pat, num_file, file);
+ if (!have_wildcard(num_pat, pat)) {
+ save_patterns(num_pat, pat, num_file, file);
+ return OK;
+ }
# ifdef HAVE_SANDBOX
/* Don't allow any shell command in the sandbox. */
@@ -1433,14 +1435,16 @@ int flags; /* EW_* flags */
return OK;
notfound:
- if (flags & EW_NOTFOUND)
- return save_patterns(num_pat, pat, num_file, file);
+ if (flags & EW_NOTFOUND) {
+ save_patterns(num_pat, pat, num_file, file);
+ return OK;
+ }
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;
char_u **pat;
int *num_file;
@@ -1449,9 +1453,8 @@ char_u ***file;
int i;
char_u *s;
- *file = (char_u **)alloc(num_pat * sizeof(char_u *));
- if (*file == NULL)
- return FAIL;
+ *file = xmalloc((size_t)num_pat * sizeof(char_u *));
+
for (i = 0; i < num_pat; i++) {
s = vim_strsave(pat[i]);
if (s != NULL)
@@ -1461,7 +1464,6 @@ char_u ***file;
(*file)[i] = s;
}
*num_file = num_pat;
- return OK;
}
/*