]> granicus.if.org Git - vim/commitdiff
patch 8.0.0526: Coverity complains about possible negative value v8.0.0526
authorBram Moolenaar <Bram@vim.org>
Thu, 30 Mar 2017 19:18:45 +0000 (21:18 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 30 Mar 2017 19:18:45 +0000 (21:18 +0200)
Problem:    Coverity complains about possible negative value.
Solution:   Check return value of ftell() not to be negative.

src/os_unix.c
src/version.c

index c78e7bf967b77a8064b1502cf8c42c1469b9f154..8ed3a67f88d29a6d0fbe96ae1935e02db3546890 100644 (file)
@@ -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);
index ba3aefc3c8e3318f9a82358eaf522c8260938fdd..436b2a1843f39ad50993425b79baaf52e8b82835 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    526,
 /**/
     525,
 /**/