summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-03-30 21:18:45 +0200
committerBram Moolenaar <Bram@vim.org>2017-03-30 21:18:45 +0200
commit85325f839a14212c7d517a4cb3464c347bfd0c1e (patch)
treee944f28003b830b09ca7b2faf8bbd00ed7fcdc47
parenta33ddbbd04ca9b81cba6114708f42b8e26293b99 (diff)
downloadvim-git-85325f839a14212c7d517a4cb3464c347bfd0c1e.tar.gz
patch 8.0.0526: Coverity complains about possible negative valuev8.0.0526
Problem: Coverity complains about possible negative value. Solution: Check return value of ftell() not to be negative.
-rw-r--r--src/os_unix.c10
-rw-r--r--src/version.c2
2 files changed, 10 insertions, 2 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index c78e7bf96..8ed3a67f8 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -6006,6 +6006,7 @@ mch_expand_wildcards(
{
int i;
size_t len;
+ long llen;
char_u *p;
int dir;
@@ -6292,9 +6293,13 @@ mch_expand_wildcards(
goto notfound;
}
fseek(fd, 0L, SEEK_END);
- len = ftell(fd); /* get size of temp file */
+ llen = ftell(fd); /* get size of temp file */
fseek(fd, 0L, SEEK_SET);
- buffer = alloc(len + 1);
+ if (llen < 0)
+ /* just in case ftell() would fail */
+ buffer = NULL;
+ else
+ buffer = alloc(llen + 1);
if (buffer == NULL)
{
/* out of memory */
@@ -6303,6 +6308,7 @@ mch_expand_wildcards(
fclose(fd);
return FAIL;
}
+ len = llen;
i = fread((char *)buffer, 1, len, fd);
fclose(fd);
mch_remove(tempname);
diff --git a/src/version.c b/src/version.c
index ba3aefc3c..436b2a184 100644
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 526,
+/**/
525,
/**/
524,