Patch 8.2.4772
Problem:    Old Coverity warning for not checking ftell() return value.
Solution:   Check return value of fseek() and ftell().
Files:      src/misc1.c


*** ../vim-8.2.4771/src/misc1.c 2022-04-15 23:29:19.410841325 +0100
--- src/misc1.c 2022-04-17 13:34:56.048904274 +0100
***************
*** 2337,2352 ****
      fd = mch_fopen((char *)tempname, READBIN);
  # endif
  
!     if (fd == NULL)
      {
!       semsg(_(e_cant_open_file_str), tempname);
        goto done;
      }
  
-     fseek(fd, 0L, SEEK_END);
-     len = ftell(fd);              // get size of temp file
-     fseek(fd, 0L, SEEK_SET);
- 
      buffer = alloc(len + 1);
      if (buffer != NULL)
        i = (int)fread((char *)buffer, (size_t)1, (size_t)len, fd);
--- 2337,2354 ----
      fd = mch_fopen((char *)tempname, READBIN);
  # endif
  
!     // Not being able to seek means we can't read the file.
!     if (fd == NULL
!           || fseek(fd, 0L, SEEK_END) == -1
!           || (len = ftell(fd)) == -1          // get size of temp file
!           || fseek(fd, 0L, SEEK_SET) == -1)   // back to the start
      {
!       semsg(_(e_cannot_read_from_str), tempname);
!       if (fd != NULL)
!           fclose(fd);
        goto done;
      }
  
      buffer = alloc(len + 1);
      if (buffer != NULL)
        i = (int)fread((char *)buffer, (size_t)1, (size_t)len, fd);
*** ../vim-8.2.4771/src/version.c       2022-04-17 13:17:36.620862242 +0100
--- src/version.c       2022-04-17 14:01:02.381636283 +0100
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4772,
  /**/

-- 
The goal of science is to build better mousetraps.
The goal of nature is to build better mice.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220417130218.24F4E1C04AA%40moolenaar.net.

Raspunde prin e-mail lui