Patch 8.2.4070
Problem:    Using uninitialized memory when reading empty file.
Solution:   Check for empty file before checking for NL. (Dominique Pellé,
            closes #9511)
Files:      src/filepath.c, src/testdir/test_eval_stuff.vim


*** ../vim-8.2.4069/src/filepath.c      2022-01-08 16:19:18.505639885 +0000
--- src/filepath.c      2022-01-12 15:20:58.786020858 +0000
***************
*** 1796,1802 ****
                p < buf + readlen || (readlen <= 0 && (prevlen > 0 || binary));
                ++p)
        {
!           if (*p == '\n' || readlen <= 0)
            {
                listitem_T  *li;
                char_u      *s  = NULL;
--- 1796,1802 ----
                p < buf + readlen || (readlen <= 0 && (prevlen > 0 || binary));
                ++p)
        {
!           if (readlen <= 0 || *p == '\n')
            {
                listitem_T  *li;
                char_u      *s  = NULL;
*** ../vim-8.2.4069/src/testdir/test_eval_stuff.vim     2021-08-04 
18:25:50.618808515 +0100
--- src/testdir/test_eval_stuff.vim     2022-01-12 15:20:58.786020858 +0000
***************
*** 93,98 ****
--- 93,105 ----
    call delete('XReadfile_bin')
  endfunc
  
+ func Test_readfile_binary_empty()
+   call writefile([], 'Xempty-file')
+   " This used to compare uninitialized memory in Vim <= 8.2.4065
+   call assert_equal([''], readfile('Xempty-file', 'b'))
+   call delete('Xempty-file')
+ endfunc
+ 
  func Test_readfile_bom()
    call writefile(["\ufeffFOO", "FOO\ufeffBAR"], 'XReadfile_bom')
    call assert_equal(['FOO', 'FOOBAR'], readfile('XReadfile_bom'))
*** ../vim-8.2.4069/src/version.c       2022-01-12 15:15:22.871212756 +0000
--- src/version.c       2022-01-12 15:23:18.337556453 +0000
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     4070,
  /**/

-- 
DINGO: Wicked wicked Zoot ... she is a bad person and she must pay the
       penalty.  And here in Castle Anthrax, we have but one punishment
       ... you must tie her down on a bed ... and spank her.  Come!
GIRLS: A spanking!  A spanking!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// 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/20220112152530.2E7FD1C05F1%40moolenaar.net.

Raspunde prin e-mail lui