Patch 8.2.4070

6 views
Skip to first unread message

Bram Moolenaar

unread,
Jan 12, 2022, 10:25:36 AM1/12/22
to vim...@googlegroups.com

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 -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages